Commit 937bcab4cb99

Vincent Demeester <vincent@sbr.pm>
2022-04-19 11:04:10
Trying to use flake-utils-plus
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent d028efc
docs/moving-home-to-nix-flakes.org
@@ -27,4 +27,8 @@
 
 * Digging into the flake
 
+- Going with flake-utils-plus. Why ?
+  For a "configuration" repository, I think it makes perfect sense. For standalone flakes,
+  like projects, … I wouldn't say the same but for this one it does.
+
 #+include: "../flake.nix"
nix/overlays/default.nix
@@ -0,0 +1,1 @@
+final: prev: { }
users/modules/modules.nix
@@ -0,0 +1,4 @@
+[
+  ./services
+  ./profiles
+]
flake.lock
@@ -105,6 +105,27 @@
         "type": "github"
       }
     },
+    "flake-utils-plus": {
+      "inputs": {
+        "flake-utils": [
+          "flake-utils"
+        ]
+      },
+      "locked": {
+        "lastModified": 1638172912,
+        "narHash": "sha256-jxhQGNEsZTdop/Br3JPS+xmBf6t9cIWRzVZFxbT76Rw=",
+        "owner": "gytis-ivaskevicius",
+        "repo": "flake-utils-plus",
+        "rev": "166d6ebd9f0de03afc98060ac92cba9c71cfe550",
+        "type": "github"
+      },
+      "original": {
+        "owner": "gytis-ivaskevicius",
+        "ref": "v1.3.1",
+        "repo": "flake-utils-plus",
+        "type": "github"
+      }
+    },
     "flake-utils_2": {
       "locked": {
         "lastModified": 1649676176,
@@ -278,6 +299,7 @@
         "emacs-overlay": "emacs-overlay",
         "flake-compat": "flake-compat_2",
         "flake-utils": "flake-utils_2",
+        "flake-utils-plus": "flake-utils-plus",
         "home-manager": "home-manager",
         "home-manager-stable": "home-manager-stable",
         "impermanence": "impermanence",
flake.nix
@@ -5,6 +5,13 @@
     # Flake for compatibility with non-flake commands
     flake-compat = { type = "github"; owner = "edolstra"; repo = "flake-compat"; flake = false; };
     flake-utils = { type = "github"; owner = "numtide"; repo = "flake-utils"; };
+    flake-utils-plus = {
+      type = "github";
+      owner = "gytis-ivaskevicius";
+      repo = "flake-utils-plus";
+      ref = "v1.3.1";
+      inputs.flake-utils.follows = "flake-utils";
+    };
     devshell = { type = "github"; owner = "numtide"; repo = "devshell"; };
 
     # Flake Dependencies
@@ -31,64 +38,79 @@
     nixpkgs-unstable = { type = "github"; owner = "NixOS"; repo = "nixpkgs"; ref = "nixpkgs-unstable"; };
   };
 
-  outputs = { self, nixpkgs, nixos-21_11, ... }@inputs:
+  outputs =
+    { self
+    , nixpkgs
+    , flake-utils-plus
+    , flake-utils
+    , home-manager
+    , emacs-overlay
+    , nur
+    , ...
+    } @ inputs:
     let
-      lib = import ./nix/lib inputs;
-      inherit (lib) genSystems;
-
-      overlays.default = import ./nix/packages;
-
-      pkgs = genSystems
-        (system:
-          import nixpkgs {
-            inherit system;
-            overlays = [
-              inputs.devshell.overlay
-              inputs.emacs-overlay.overlay
-              overlays.default
-            ];
-
-            config.allowUnfree = true;
-          });
-      stablePkgs = genSystems
-        (system:
-          import nixos-21_11 {
-            inherit system;
-            overlays = [
-              inputs.devshell.overlay
-              inputs.emacs-overlay.overlay
-              overlays.default
-            ];
-
-            config.allowUnfree = true;
-          });
+      mkApp = flake-utils.lib.mkApp;
+      homeProfiles = import ./home { inherit (nixpkgs) lib; };
     in
-    {
-      inherit lib overlays pkgs;
+    flake-utils-plus.lib.mkFlake {
+      inherit self inputs;
 
-      # Standalone home-manager config
-      inherit (import ./home/profiles inputs) homeConfigurations;
+      supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
+      channelsConfig.allowUnfree = true;
 
-      deploy = import ./hosts/deploy.nix inputs;
+      sharedOverlays = [
+        (import ./nix/overlays)
+        emacs-overlay.overlay
+        nur.overlay
+      ];
 
-      # NixOS configuration with home-manager
-      nixosConfigurations = import ./systems/hosts inputs;
+      hostDefaults = {
+        system = "x86_64-linux";
+        channelName = "nixos-unstable";
+        extraArgs = {
+          # nixos/profiles/core.nix requires self parameter
+          inherit self;
+        };
+        modules = [
+          ./systems/modules
+          home-manager.nixosModules.home-manager
+          {
+            # Import custom home-manager modules (NixOS)
+            config.home-manager.sharedModules = import ./users/modules/modules.nix;
+          }
+        ];
+      };
 
-      # devShells = genSystems (system: {
-      #   default = pkgs.${system}.devshell.mkShell {
-      #     packages = with pkgs.${system}; [
-      #       git
-      #       nixpkgs-fmt
-      #       inputs.deploy-rs.defaultPackage.${system}
-      #       # repl
-      #     ];
-      #     name = "dots";
-      #   };
-      # });
+      hosts = {
+        naruhodo = {
+          modules = [ ./systems/hosts/naruhodo.nix ];
+        };
+        okinawa = {
+          modules = [ ./systems/hosts/okinawa.nix ];
+        };
+        shikoku = {
+          channelName = "nixos-21_11";
+          modules = [ ./systems/hosts/shikoku.nix ];
+        };
+      };
 
-      packages = lib.genAttrs [ "x86_64-linux" ] (system: {
-        inherit (pkgs.${system})
-          ;
-      });
+      outputsBuilder = channels:
+        let
+        in
+        {
+          overlay = import ./nix/overlays;
+          devShell = with channels.nixpkgs; mkShell {
+            sopsPGPKeyDirs = [ "./secrets/keys" ];
+            nativeBuildInputs = [
+              (pkgs.callPackage pkgs.sops-nix { }).sops-import-keys-hook
+            ];
+            buildInputs = with pkgs; [
+              cachix
+              git
+              nixpkgs-fmt
+              sops
+            ];
+          };
+        };
     };
 }