summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 5ccb5d4a9c011ecf49ca0c2dbfbf888932bd328e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
    unstable.url = "github:nixos/nixpkgs/nixos-unstable";

    disko.url = "github:nix-community/disko/latest";
    disko.inputs.nixpkgs.follows = "nixpkgs";

    impermanence.url = "github:nix-community/impermanence";

    agenix.url = "github:ryantm/agenix";
    agenix.inputs.nixpkgs.follows = "nixpkgs";
    agenix.inputs.darwin.follows = "";
  };
  outputs =
    inputs@{
      self,
      nixpkgs,
      unstable,
      ...
    }:
    let
      forAllSystems =
        f:
        nixpkgs.lib.genAttrs
          [ "x86_64-linux" "aarch64-linux" ]
          (system: f { inherit system; pkgs = import nixpkgs { inherit system; }; });
    in
    {
      nixosConfigurations.oden = nixpkgs.lib.nixosSystem {
        modules = [
          ./configuration.nix
        ];
        specialArgs = {
          inherit inputs;
        };
      };
      packages = forAllSystems ({ system, pkgs }: {
        deploy = pkgs.writeShellScriptBin "deploy" ''
          [ -n "$1" ] && action="$1" || action="switch"
          nixos-rebuild --flake .#oden "$action" --target-host oden --build-host oden --use-remote-sudo
        '';
      });
      devShells = forAllSystems ({ system, pkgs }: {
        default = pkgs.mkShellNoCC {
          packages = [
            inputs.agenix.packages.${system}.agenix
            self.packages.${pkgs.system}.deploy
          ];
        };
      });
    };
}