diff --git a/flake.lock b/flake.lock index 242c1b6..c2dfbc0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,22 +1,57 @@ { "nodes": { - "nixpkgs": { + "flake-utils": { "locked": { - "lastModified": 1632753066, - "narHash": "sha256-oLs+Jm9zSRUVhTzPzKbQByLPor4IxdhZ6xUThAE1+s0=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "1224e4bec7b8019f8847dd268a642000073bcfa3", + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", "type": "github" }, "original": { - "id": "nixpkgs", - "ref": "release-21.05", - "type": "indirect" + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils-plus": { + "inputs": { + "flake-utils": "flake-utils" + }, + "locked": { + "lastModified": 1657226504, + "narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1665466769, + "narHash": "sha256-L+qcHpb4Ac3PipMXJY/Ktbu1+KXy23WCZ8pXWmsf7zY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0b20bf89e0035b6d62ad58f9db8fdbc99c2b01e8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-22.05", + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { + "flake-utils-plus": "flake-utils-plus", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index aced12f..63e09bb 100644 --- a/flake.nix +++ b/flake.nix @@ -1,56 +1,53 @@ { description = "Base16-template builder for nix."; - inputs.nixpkgs.url = "nixpkgs/release-21.05"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/release-22.05"; + flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus"; + }; + + outputs = { self, nixpkgs, flake-utils-plus }@inputs: + flake-utils-plus.lib.mkFlake rec { + inherit self inputs; + supportedSystems = [ + "x86_64-linux" "aarch64-linux" + "x86_64-darwin" "aarch64-darwin" + ]; + + channels.stable.input = nixpkgs; + + outputsBuilder = channels: let + pkgs = channels.stable; + in rec { + packages.update-base16 = let + binPath = with pkgs; lib.makeBinPath [ curl nix-prefetch-git gnused jq ]; + in pkgs.writeShellScriptBin "update-base16" '' + PATH="$PATH:${binPath}" + generate_sources () { + out=$1 + curl "https://raw.githubusercontent.com/chriskempson/base16-$out-source/master/list.yaml"\ + | sed -nE "s~^([-_[:alnum:]]+): *(.*)~\1 \2~p"\ + | while read name src; do + echo "{\"key\":\"$name\",\"value\":" + nix-prefetch-git $src + echo "}" + done\ + | jq -s ".|del(.[].value.date)|from_entries"\ + > $out.json + } + generate_sources templates & + generate_sources schemes & + wait + ''; + + defaultPackage = packages.update-base16; + + devShell = pkgs.mkShell { + inputs = [ packages.update-base16 ]; + }; + }; - outputs = { self, nixpkgs }@inputs: - with nixpkgs.legacyPackages."x86_64-linux"; rec { # Home-Manager Module hmModule = ./base16.nix; - - packages.x86_64-linux.update-base16 = (let - mkScript = { name, file, env ? [ ] }: - writeTextFile { - name = "${name}"; - executable = true; - destination = "/bin/${name}"; - text = '' - for i in ${lib.concatStringsSep " " env}; do - export PATH="$i/bin:$PATH" - done - exec ${bash}/bin/bash ${file} $@ - ''; - }; - in mkScript rec { - name = "update-base16"; - env = [ curl nix-prefetch-git gnused jq ]; - file = writeTextFile { - name = "${name}.sh"; - executable = true; - text = '' - generate_sources () { - out=$1 - curl "https://raw.githubusercontent.com/chriskempson/base16-$out-source/master/list.yaml"\ - | sed -nE "s~^([-_[:alnum:]]+): *(.*)~\1 \2~p"\ - | while read name src; do - echo "{\"key\":\"$name\",\"value\":" - nix-prefetch-git $src - echo "}" - done\ - | jq -s ".|del(.[].value.date)|from_entries"\ - > $out.json - } - generate_sources templates & - generate_sources schemes & - wait - ''; - }; - }); - - defaultPackage.x86_64-linux = packages.x86_64-linux.update-base16; - - devShell.x86_64-linux = mkShell { - buildInputs = [ packages.x86_64-linux.update-base16 ]; - }; }; }