summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 5fdeb7e2ad5b112f9a8dd9330375559a687f75a3 (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
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
    nixpkgsUnstable.url = "github:nixos/nixpkgs";

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

    nur.url = "github:nix-community/NUR";
    impermanence.url = "github:nix-community/impermanence";
    hm-isolation.url = "/home/ale/hm-isolation";
  };

  outputs =
    { self, nixpkgs, nixpkgsUnstable, home-manager
    , nur, impermanence, hm-isolation, ... }:
    with nixpkgs.lib; let
      util = import ./util;
      inherit (util nixpkgs.lib) importAll;

      pkgSet = pkgs: import ./pkgs pkgs;
    in {
      packages."x86_64-linux" = pkgSet nixpkgs.legacyPackages."x86_64-linux";

      overlay = self: super: {
        local = pkgSet super;
        unstable = import nixpkgsUnstable { inherit (super) config system; };
      };

      nixosConfigurations = let
        hostConfig = host: (makeOverridable nixosSystem) {
          system = "x86_64-linux";
          modules = [ (import ./sys { inherit self impermanence; }) host ];
        };
      in mapAttrs (_: hostConfig) (importAll { root = ./sys/platform; });

      homeConfigurations = let
        configuration = import ./home {
          inherit self nixpkgs nixpkgsUnstable nur hm-isolation;
        };

        username = "ale";

        home = platform: home-manager.lib.homeManagerConfiguration {
          system = "x86_64-linux";

          inherit configuration;
          extraModules = [ platform ];

          inherit username;
          homeDirectory = "/home/${username}";

          # Update the state version as needed.
          # See the changelog here:
          # https://nix-community.github.io/home-manager/release-notes.html#sec-release-21.05
          stateVersion = "21.11";

          # Optionally use extraSpecialArgs
          # to pass through arguments to home.nix
          extraSpecialArgs = {};
        };

        platformHome = name: platform: {
          name = "${username}@${name}";
          value = home platform;
        };
      in mapAttrs' platformHome (importAll { root = ./home/platform; });
    };
}