From 92cc765580fc16e276c65d6c43ef953de98da725 Mon Sep 17 00:00:00 2001 From: Grey Jones Date: Sat, 29 Aug 2026 15:07:43 +0100 Subject: [PATCH] initial commit --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 23 +++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6020ba5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1787736819, + "narHash": "sha256-cV5xEJJK3BvhU8rEd4mC9UsmDi5qscv/kzGPhBRC5WA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9fbb54b33e91ee4ca368e35a78e0613c720600b3", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6d2c27e --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + description = "A flake that provides a set of useful helper functions"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: { + mkIfElse = with nixpkgs.lib; p: yes: no: mkMerge [ + (mkIf p yes) + (mkIf (!p) no) + ]; + + mkSymlinkActivationScript = {target, source, isDir ? false}: '' + if [ ${if isDir then "-d" else "-f"} ${target} ]; then + rm${if isDir then " -rf" else ""} ${target} + fi + ln -s ${source} ${target} + ''; + + attrByStrPath = strPath: set: nixpkgs.lib.attrsets.attrByPath (nixpkgs.lib.strings.splitString "." strPath) null set; + }; +}