]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - deploy/flake.nix
Squash changes containing private information
[perso/Immae/Config/Nix.git] / deploy / flake.nix
diff --git a/deploy/flake.nix b/deploy/flake.nix
new file mode 100644 (file)
index 0000000..f613b19
--- /dev/null
@@ -0,0 +1,45 @@
+{
+  inputs = {
+    devshell.url = "github:numtide/devshell";
+    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable?dir=lib";
+    # Uncomment temporarily below value and replace with local path to
+    # your secrets, and replace "follows" key below to use it.
+    #secrets-local.url = "path:/home/immae/projets/mes_sites/nixops-secrets";
+    secrets = {
+      type = "git";
+      url = "git+ssh://gitolite@git.immae.eu/perso/Immae/Config/Nix/Nixops/Secrets";
+      ref = "master";
+    };
+    main-flake.url = "path:../flakes";
+    main-flake.inputs.secrets.follows = "secrets";
+  };
+  outputs = inputs@{ self, nixpkgs, main-flake, devshell, ... }: {
+    sops-vars-file = (inputs.secrets-local or inputs.secrets).vars-file;
+    # FIXME: next line Can be removed in nix 2.16.*
+    devShell.x86_64-linux = self.devShells.x86_64-linux.default;
+    devShells.x86_64-linux.default = devshell.legacyPackages.x86_64-linux.mkShell {
+      env = [
+        { name = "NIX_BUILD_TOP"; value = ""; }
+        { name = "SOPS_VARS_FILE"; value = builtins.toString self.sops-vars-file; }
+      ];
+    };
+    colmena =
+      let
+        nodeFlakes = main-flake.subflakes.nodes;
+        hosts = builtins.attrNames nodeFlakes;
+        toHostNixpkgs = name: nodeFlakes.${name}.colmena.meta.nixpkgs;
+        toHostSpecialArgs = name: nodeFlakes.${name}.colmena.meta.specialArgs;
+        toHostColmena = name: nodeFlakes.${name}.colmena.${name};
+
+      in nixpkgs.lib.genAttrs hosts toHostColmena
+        // {
+        meta = {
+          # nixpkgs is required for colmena, but only lib is actually used
+          nixpkgs.lib = nixpkgs.lib;
+          specialArgs.secrets = main-flake.subflakes.secrets;
+          nodeNixpkgs = nixpkgs.lib.genAttrs hosts toHostNixpkgs;
+          nodeSpecialArgs = nixpkgs.lib.genAttrs hosts toHostSpecialArgs;
+        };
+      };
+  };
+}