summaryrefslogtreecommitdiff
path: root/flake.nix
blob: ae851c7051603941298b388824fe4135c8fbd2a2 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
  description = "NixOS configuration";

  inputs = {
    # nixpkgs
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    # home manager
    home-manager.url = "github:nix-community/home-manager/master";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    # hyprland
    hyprland.url = "github:hyprwm/Hyprland/v0.55.0";
    hyprland.inputs.nixpkgs.follows = "nixpkgs";
    # hyprland plugins
    hyprland-plugins.url = "github:hyprwm/hyprland-plugins/v0.55.0";
    hyprland-plugins.inputs.hyprland.follows = "hyprland";
    # hyprland hy3
    hy3.url = "github:outfoxxed/hy3/hl0.55.0";
    hy3.inputs.hyprland.follows = "hyprland";
    # sops
    sops-nix.url = "github:Mic92/sops-nix";
    sops-nix.inputs.nixpkgs.follows = "nixpkgs";
    # talc
    talc.url = "git+https://g.trimill.xyz/talc";
    talc.inputs.nixpkgs.follows = "nixpkgs";
    # apple-fonts
    apple-fonts.url = "github:Lyndeno/apple-fonts.nix";
    apple-fonts.inputs.nixpkgs.follows = "nixpkgs";
    # nixos-wsl
    nixos-wsl.url = "github:nix-community/nixos-wsl";
    nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";
    # nixos-hardware
    nixos-hardware.url = "github:nixos/nixos-hardware/master";
    # caelestia-shell
    caelestia-shell.url = "git+https://g.freya.cat/caelestia-shell";
    caelestia-shell.inputs.nixpkgs.follows = "nixpkgs";
    # nix-gaming
    nix-gaming.url = "github:fufexan/nix-gaming";
    nix-gaming.inputs.nixpkgs.follows = "nixpkgs";
    # nix-cachyos-kernel
    nix-cachyos-kernel.url = "github:xddxdd/nix-cachyos-kernel/release";
  };

  outputs = {
    self,
    nixpkgs,
    home-manager,
    ...
  } @ inputs: let
    systems = ["x86_64-linux"];
    perSystem = func:
      builtins.listToAttrs (map (
          system: let
            pkgs = nixpkgs.legacyPackages.${system};
          in {
            name = system;
            value = func pkgs system;
          }
        )
        systems);
    mkSystem = hostDir: system: let
      lib = nixpkgs.lib.extend (_: _: self.lib);
    in
      lib.nixosSystem {
        inherit system;
        specialArgs = {inherit inputs system hostDir lib;};
        modules = [
          ./system
          ./options.nix
          hostDir
        ];
      };
    mkHome = hostDir: system: let
      hostModule = mkSystem hostDir system;
      lib = nixpkgs.lib.extend (_: _: self.lib);
    in
      home-manager.lib.homeManagerConfiguration {
        inherit (hostModule) pkgs;
        extraSpecialArgs = {inherit inputs system hostDir lib;};
        modules = [
          ./home
          ./options.nix
          (self.lib.homeConfig hostModule.config)
          {
            programs.home-manager.enable = nixpkgs.lib.mkForce false;
          }
        ];
      };
  in rec {
    nixosConfigurations = {
      shinji = mkSystem ./hosts/shinji "x86_64-linux";
      kaworu = mkSystem ./hosts/kaworu "x86_64-linux";
      thinkpad = mkSystem ./hosts/thinkpad "x86_64-linux";
      wsl = mkSystem ./hosts/wsl "x86_64-linux";
    };

    homeConfigurations = {
      shinji = mkHome ./hosts/shinji "x86_64-linux";
      kaworu = mkHome ./hosts/kaworu "x86_64-linux";
      thinkpad = mkHome ./hosts/thinkpad "x86_64-linux";
      wsl = mkHome ./hosts/wsl "x86_64-linux";
      kagamine = mkHome ./hosts/work "x86_64-linux";
    };

    lib = import ./lib {
      inherit (nixpkgs) lib;
    };

    packages = perSystem (
      pkgs: system:
        import ./pkgs {
          final = pkgs;
        }
    );

    legacyPackages = packages;

    formatter = perSystem (
      pkgs: _:
        pkgs.alejandra
    );

    devShells = perSystem (
      pkgs: system:
        import ./shells {
          inherit pkgs;
          inherit system;
          inherit inputs;
        }
    );
  };
}