summary refs log tree commit diff
path: root/flake.nix
blob: b8e1a8f32415245c73a86605c8930a0220b09935 (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
94
95
96
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";

    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";

    home-manager = {
      url = "github:nix-community/home-manager/release-24.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    agenix = {
      url = "github:ryantm/agenix";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.home-manager.follows = "home-manager";
    };

    nix-vscode-extensions = {
      url = "github:nix-community/nix-vscode-extensions";
      inputs.nixpkgs.follows = "nixpkgs-unstable";
    };

    flake-compat.url = "github:edolstra/flake-compat";
  };

  outputs =
    inputs@{
      self,
      nixpkgs,
      nixpkgs-unstable,
      agenix,
      home-manager,
      nix-vscode-extensions,
      ...
    }:
    let
      system = "x86_64-linux";

      machines = [
        "graphite"
        "bismuth"
      ];

      overlays = [
        agenix.overlays.default
        nix-vscode-extensions.overlays.default
      ];

      packageSets =
        let
          commonPkgsInputs = {
            inherit system;
            config = import ./config.nix;
          };
        in
        rec {
          pkgs = import nixpkgs (commonPkgsInputs // { inherit overlays; });

          unstablePkgs = import nixpkgs-unstable commonPkgsInputs;

          auxiliaryPkgs = import ./pkgs { inherit pkgs unstablePkgs; };
        };

    in
    {
      nixosConfigurations = nixpkgs.lib.genAttrs machines (
        machine:
        nixpkgs.lib.nixosSystem {
          inherit system;

          specialArgs =
            inputs
            // packageSets
            // {
              me = machine;
            };

          modules = [
            ./machines/${machine}

            home-manager.nixosModules.home-manager
            {
              home-manager.useGlobalPkgs = true;
              home-manager.useUserPackages = true;
              home-manager.users.mel = import ./machines/${machine}/home.nix;
            }

            agenix.nixosModules.default
          ];
        }
      );

      # compatibility wrapper for nixos-option
      legacyPackages.${system} = with packageSets; pkgs.recurseIntoAttrs pkgs;
    };
}