summaryrefslogtreecommitdiff
path: root/flake.nix
blob: eb4cfcb52611d95021ff1ab1b6ac96998b3f73c9 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{
  description = ''
   stuebinm's flake stuff. feel free to reuse parts you find useful, but
   I suggest you don't depend on any of them actually working.
  '';

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nixpkgs-review.url = "github:dotlambda/nixpkgs/mollysocket-init";

    home-manager.url = "github:nix-community/home-manager/release-23.11";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    deploy-rs.url = "git+https://stuebinm.eu/git/forks/deploy-rs?ref=nom-flag";
    deploy-rs.inputs.nixpkgs.follows = "nixpkgs";
    simple-nixos-mailserver.url =
      "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-23.11";
    simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs-unstable";
    simple-nixos-mailserver.inputs.nixpkgs-23_05.follows = "nixpkgs";
    simple-nixos-mailserver.inputs.nixpkgs-23_11.follows = "nixpkgs";
    rust-overlay.url = "github:oxalica/rust-overlay";
    rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
    sops-nix.url = "github:Mic92/sops-nix";
    sops-nix.inputs.nixpkgs.follows = "nixpkgs-unstable";
    sops-nix.inputs.nixpkgs-stable.follows = "nixpkgs";

    uplcg.url = "git+https://stuebinm.eu/git/forks/uplcg?ref=main";
    uplcg.flake = false;
    tracktrain.url = "git+https://stuebinm.eu/git/tracktrain?ref=main";
    tracktrain.flake = false;
    blog.url = "git+ssh://cgit/~/blog";
    blog.flake = false;
    playground.url = "git+https://stuebinm.eu/git/playground";
    playground.flake = false;
    traveltext.url = "git+https://stuebinm.eu/git/traveltext?ref=main";
    traveltext.flake = false;
    showrt.url = "git+https://stuebinm.eu/git/showrt?ref=main";
    showrt.flake = false;
    almanac.url = "git+https://stuebinm.eu/git/forks/almanac";
    almanac.flake = false;
    feeds.url = "path:/home/stuebinm/org/nonpublic.nix";
    feeds.flake = false;
    isabelle-utils.url = "git+https://stuebinm.eu/git/isabelle-utils";
    isabelle-utils.flake = false;
    bahnhof-name.url = "git+https://stuebinm.eu/git/bahnhof.name";
    bahnhof-name.flake = false;
    ntfy-matrix-bot.url = "git+https://stuebinm.eu/git/ntfy-matrix-bot";
    ntfy-matrix-bot.flake = false;

    gtfsBooks.url = "git+https://stuebinm.eu/git/forks/gtfs-books?ref=main";
    gtfsBooks.flake = false;
    walint.url = "git+https://stuebinm.eu/git/walint?ref=playground";
    walint.flake = false;
  };

  outputs = { self, deploy-rs, sops-nix, ... }@inputs:
    let
      nixpkgs = import inputs.nixpkgs {
        system = "x86_64-linux";
        overlays = [
          inputs.rust-overlay.overlays.default
          self.overlays.default
        ];
        config.permittedInsecurePackages = [
          "schildichat-web-1.11.30-sc.2"
        ];
      };
      mkConfig = imports: config:
        inputs.nixpkgs.lib.nixosSystem rec {
          system = "x86_64-linux";
          modules = [ config ] ++ imports;
          extraModules = builtins.attrValues self.nixosModules;
          pkgs = nixpkgs;

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

      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 = 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 = deploy-rs.lib.x86_64-linux.activate.nixos
              self.nixosConfigurations.abbenay;
          };
        };
      };

      checks = builtins.mapAttrs
        (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;

      homeConfigurations = let
        home = root:
          inputs.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;

      overlays.default = final: prev:
        import ./pkgs/overlay.nix { inherit inputs; } final prev;
      packages.x86_64-linux = {
        inherit (nixpkgs)
          galmon-core galmon-full almanac rustex
          kijetesantakaluotokieni showrt isabelle-utils isabat
          travelynx crs-tracker crs-php bahnhof-name matrix-to
          hikari_unstable heartwood radicle-interface radicle-tui
          inweb nomsring bookwyrm mollysocket git-annex-remote-remarkable2
          ntfy-matrix-bot;

        tests.bookwyrm = nixpkgs.nixosTest ./tests/bookwyrm.nix;
      };

      nixosModules = {
        # glitchtip = import ./modules/glitchtip.nix;
        bookwyrm = import ./modules/bookwyrm.nix;
        # mollysocket = import ./modules/mollysocket.nix;
        mollysocket = import "${inputs.nixpkgs-review.outPath}/nixos/modules/services/misc/mollysocket.nix";
      };

      hydraJobs = {
        inherit (self) packages home;
      };
    };
}