From c4033ff00a00bdd89017053c93a859ee419b0947 Mon Sep 17 00:00:00 2001 From: Kat Inskip Date: Sat, 3 Dec 2022 17:54:34 +0100 Subject: [PATCH] feat: empty flake, reduce lockfile, flake-utils-plus --- default.nix | 73 +++++++++++++++-------- flake.lock | 163 +++++++++++++++++++++++++++------------------------- flake.nix | 20 ++++++- 3 files changed, 153 insertions(+), 103 deletions(-) diff --git a/default.nix b/default.nix index afa9e274..a15d27e5 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ nixpkgs, darwin, home-manager, ragenix, scalpel, ... }@inputs: let +{ self, utils, nixpkgs, darwin, home-manager, ragenix, scalpel, mach-nix, ... }@inputs: let tree = (inputs.tree.tree { inherit inputs; folder = ./.; @@ -16,38 +16,54 @@ }).impure; lib = inputs.nixpkgs.lib; inherit (lib.attrsets) mapAttrs; -in { - inherit tree; - nixosConfigurations = let base = mapAttrs (name: path: nixpkgs.lib.nixosSystem { - specialArgs = { - inherit inputs tree; - machine = name; - }; + inherit (lib.lists) singleton; +in utils.lib.mkFlake { + inherit self inputs; + supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ]; + channelsConfig.allowUnfree = true; + + hostDefaults = { system = "x86_64-linux"; modules = [ home-manager.nixosModules.home-manager ragenix.nixosModule - path ]; - } ) tree.nixos.systems; in mapAttrs (_: sys: sys.extendModules { + extraArgs = { + inherit utils inputs tree; + }; + }; + + hosts = let + outputForSystem = system: { + "x86_64-linux" = "nixosConfigurations"; + "aarch64-darwin" = "darwinConfigurations"; + }.${system}; + builderForSystem = system: { + "x86_64-linux" = nixpkgs.lib.nixosSystem; + "aarch64-darwin" = darwin.lib.darwinSystem; + }.${system}; + mapSystem = system: name: path: { + inherit system; + output = outputForSystem system; + builder = builderForSystem system; + modules = singleton path; + extraArgs = { + machine = name; + }; + }; + in mapAttrs (mapSystem "x86_64-linux") tree.nixos.systems + // mapAttrs (mapSystem "aarch64-darwin") tree.darwin.systems; + + outputsBuilder = channels: { + nixosConfigurations = mapAttrs(_: sys: sys.extendModules { modules = [ scalpel.nixosModule ]; specialArgs = { prev = sys; }; - } ) base; - darwinConfigurations = mapAttrs (name: path: darwin.lib.darwinSystem { - specialArgs = { - inherit inputs tree; - machine = name; - }; - system = "aarch64-darwin"; - modules = [ - home-manager.nixosModules.home-manager - path - ]; - } ) tree.darwin.systems; + }) self.nixosConfigurations; + homeManagerConfigurations = mapAttrs (name: path: home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; + pkgs = channels.nixpkgs; extraSpecialArgs = { inherit inputs tree; machine = name; @@ -57,4 +73,15 @@ in { path ]; }) tree.home; + + inherit tree; + }; + + devShells = { + "python" = mach-nix.mkPythonShell { + python = "python310"; + requirements = '' + ''; + }; + }; } diff --git a/flake.lock b/flake.lock index e0ef82b3..d354f56a 100644 --- a/flake.lock +++ b/flake.lock @@ -42,13 +42,28 @@ "type": "github" } }, + "empty": { + "locked": { + "lastModified": 1630400035, + "narHash": "sha256-MWaVOCzuFwp09wZIW9iHq5wWen5C69I940N1swZLEQ0=", + "owner": "input-output-hk", + "repo": "empty-flake", + "rev": "2040a05b67bf9a669ce17eca56beb14b4206a99a", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "empty-flake", + "type": "github" + } + }, "flake-utils": { "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", "type": "github" }, "original": { @@ -65,11 +80,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1669825171, - "narHash": "sha256-HxlZHSiRGXnWAFbIJMeujqBe2KgACYx5XDRY0EA9P+4=", + "lastModified": 1670058827, + "narHash": "sha256-T+yyncPpZWeIkFrG/Cgj21iopULY3BZGWIhcT5ZmCgM=", "owner": "nix-community", "repo": "home-manager", - "rev": "478610aa37c8339eacabfa03f07dacf5574edd47", + "rev": "eb3598cf44aa10f2a16fe38488a102c0f474d766", "type": "github" }, "original": { @@ -79,13 +94,37 @@ "type": "github" } }, + "mach-nix": { + "inputs": { + "flake-utils": [ + "utils" + ], + "nixpkgs": [ + "nixpkgs" + ], + "pypi-deps-db": "pypi-deps-db" + }, + "locked": { + "lastModified": 1654084003, + "narHash": "sha256-j/XrVVistvM+Ua+0tNFvO5z83isL+LBgmBi9XppxuKA=", + "owner": "DavHau", + "repo": "mach-nix", + "rev": "7e14360bde07dcae32e5e24f366c83272f52923f", + "type": "github" + }, + "original": { + "id": "mach-nix", + "ref": "3.5.0", + "type": "indirect" + } + }, "nixpkgs": { "locked": { - "lastModified": 1669791787, - "narHash": "sha256-KBfoA2fOI5+wCrm7PR+j7jHqXeTkVRPQ0m5fcKchyuU=", + "lastModified": 1669969257, + "narHash": "sha256-mOS13sK3v+kfgP+1Mh56ohiG8uVhLHAo7m/q9kqAehc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e76c78d20685a043d23f5f9e0ccd2203997f1fb1", + "rev": "b72b8b94cf0c012b0252a9100a636cad69696666", "type": "github" }, "original": { @@ -95,51 +134,19 @@ "type": "github" } }, - "nixpkgs-21_11": { + "pypi-deps-db": { + "flake": false, "locked": { - "lastModified": 1654346688, - "narHash": "sha256-Y7QtZkfdxTvACCvWmDjpN6qOf4OKkZATufHcJP2VMKM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "2de556c4cd46a59e8ce2f85ee4dd400983213d45", + "lastModified": 1643877077, + "narHash": "sha256-jv8pIvRFTP919GybOxXE5TfOkrjTbdo9QiCO1TD3ZaY=", + "owner": "DavHau", + "repo": "pypi-deps-db", + "rev": "da53397f0b782b0b18deb72ef8e0fb5aa7c98aa3", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "release-21.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-22_05": { - "locked": { - "lastModified": 1654373220, - "narHash": "sha256-3vKFnZz2oYHo4YcelaNOhO4XQ2jiIEXrp1s4w+e773c=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d6cb04299ce8964290ae7fdcb87aa50da0500b5c", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "release-22.05", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1654245945, - "narHash": "sha256-PV6MZ+HuNnyLxQGa2rwt0BmCRkQS2xqhc+SeJLQM+WU=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "442db9429b9fbdb6352cfb937afc8ecccfe2633f", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", + "owner": "DavHau", + "repo": "pypi-deps-db", "type": "github" } }, @@ -147,7 +154,7 @@ "inputs": { "agenix": "agenix", "flake-utils": [ - "flake-utils" + "utils" ], "nixpkgs": [ "nixpkgs" @@ -171,12 +178,14 @@ "root": { "inputs": { "darwin": "darwin", - "flake-utils": "flake-utils", + "empty": "empty", "home-manager": "home-manager", + "mach-nix": "mach-nix", "nixpkgs": "nixpkgs", "ragenix": "ragenix", "scalpel": "scalpel", - "tree": "tree" + "tree": "tree", + "utils": "utils_2" } }, "rust-overlay": { @@ -209,7 +218,9 @@ "nixpkgs": [ "nixpkgs" ], - "sops-nix": "sops-nix" + "sops-nix": [ + "empty" + ] }, "locked": { "lastModified": 1655566736, @@ -225,26 +236,6 @@ "type": "github" } }, - "sops-nix": { - "inputs": { - "nixpkgs": "nixpkgs_2", - "nixpkgs-21_11": "nixpkgs-21_11", - "nixpkgs-22_05": "nixpkgs-22_05" - }, - "locked": { - "lastModified": 1654401128, - "narHash": "sha256-uCdQ2fzIPGakHw2TkvOncUvCl7Fo7z/vagpDWYooO7s=", - "owner": "Mic92", - "repo": "sops-nix", - "rev": "f075361ecbde21535b38e41dfaa28a28f160855c", - "type": "github" - }, - "original": { - "owner": "Mic92", - "repo": "sops-nix", - "type": "github" - } - }, "tree": { "inputs": { "nixpkgs": [ @@ -252,11 +243,11 @@ ] }, "locked": { - "lastModified": 1669922720, - "narHash": "sha256-xzoKL4RtKRECdrWHAM14OBaNdJRToc+AA9zmUWuo5eY=", + "lastModified": 1670085069, + "narHash": "sha256-IO9HcAjncPp/0sUGcCUWVwa0XoBVFQKx+oY+8EBRcTc=", "owner": "kittywitch", "repo": "tree", - "rev": "fbe8ae96d7f4fb369d32dbbe8434606b23354caf", + "rev": "501675588cb663a9bd18056002de697f4e91b667", "type": "github" }, "original": { @@ -279,6 +270,24 @@ "repo": "flake-utils", "type": "github" } + }, + "utils_2": { + "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" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index c0229a52..e07c86ce 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,7 @@ { description = "kat's personal system flakes"; inputs = { + empty.url = "github:input-output-hk/empty-flake"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; home-manager = { url = "github:nix-community/home-manager/master"; @@ -10,7 +11,7 @@ url = "github:lnl7/nix-darwin/master"; inputs.nixpkgs.follows = "nixpkgs"; }; - flake-utils.url = "github:numtide/flake-utils"; + utils.url = "github:gytis-ivaskevicius/flake-utils-plus"; tree = { url = "github:kittywitch/tree"; inputs.nixpkgs.follows = "nixpkgs"; @@ -19,12 +20,25 @@ url = "github:yaxitech/ragenix"; inputs = { nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; + flake-utils.follows = "utils"; }; }; scalpel = { url = "github:polygon/scalpel"; - inputs.nixpkgs.follows = "nixpkgs"; + inputs = { + nixpkgs.follows = "nixpkgs"; + # i get that you have to test shit, but isn't throwing sops-nix and thus three + # whole fucking versions of nixpkgs into shit a little excessive? + # fuck the sops-nix people to begin with :/ + sops-nix.follows = "empty"; + }; + }; + mach-nix = { + url = "mach-nix/3.5.0"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "utils"; + }; }; }; outputs = { ... }@inputs: import ./default.nix inputs;