summaryrefslogtreecommitdiff
path: root/default.nix
blob: 1d100d15ce45b6934ecdeaf6c4a6e4470286bc98 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{ system ? "x86_64-linux"
, inputs ? import ./inputs.nix { inherit system; }
}:

let
  inherit (inputs) sops-nix home-manager nixpkgs;

  mkConfig = imports: config:
    inputs.nixpkgs-flake.lib.nixosSystem rec {
      system = "x86_64-linux";
      modules = [ config ] ++ imports;
      extraModules =
        builtins.attrValues self.modules
        ++ [ sops-nix ];
      pkgs = nixpkgs;

      specialArgs = {
        inherit inputs system;
        craneLib = inputs.crane.lib.${system};
      };
    };
  mkDesktop = mkConfig [ ./common/desktop.nix ];
  mkServer = mkConfig [
    ./common/headless.nix
  ];
  deploy-vps = hostname: {
    inherit hostname;
    profiles.system = {
      user = "root";
      sshUser = "root";
      path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos
        self.nixosConfigurations.${hostname};
    };
  };

  self = {

    nixosConfigurations = {
      chaski = mkServer ./chaski/configuration.nix;
      flora = mkServer ./flora/configuration.nix;
      abbenay = mkDesktop ./abbenay/configuration.nix;
      cyberbox = mkDesktop ./cyberbox/configuration.nix;
      ilex = mkDesktop ./ilex/configuration.nix;
    };

    deploy.nodes = {
      chaski = deploy-vps "chaski";
      flora = deploy-vps "flora";
      parsons = {
        hostname = "parsons";
        profiles.home = {
          user = "stuebinm";
          sshUser = "stuebinm";
          path = inputs.deploy-rs.lib.x86_64-linux.activate.home-manager
            self.homeConfigurations.stuebinm-minimal;
        };
      };
      abbenay = {
        hostname = "abbenay";
        profiles.system = {
          user = "root";
          sshUser = "stuebinm";
          interactiveSudo = true;
          path = inputs.deploy-rs.lib.x86_64-linux.activate.nixos
            self.nixosConfigurations.abbenay;
        };
      };
    };

    homeConfigurations = let
      home = root:
        home-manager.lib.homeManagerConfiguration rec {
          pkgs = nixpkgs;
          modules = [ root ];
          extraSpecialArgs = {
            inherit inputs;
            system = "x86_64-linux";
          };
        };
    in {
      stuebinm = home ./home/home.nix;
      stuebinm-minimal = home ./home/home-minimal.nix;
    };

    home = self.homeConfigurations.stuebinm.activationPackage;
    home-minimal = self.homeConfigurations.stuebinm-minimal.activationPackage;

    modules = import ./modules;
    packages = import ./pkgs { inherit nixpkgs; };
    tests = import ./tests { inherit nixpkgs; };
  };

in self