summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 1814c761be683efb3e7061907b272fb25254a7d8 (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
{
  description = "testing nix flakes for server deployment";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    home-manager.url = "github:nix-community/home-manager/release-22.11";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    naersk.url = "github:nix-community/naersk";
    naersk.inputs.nixpkgs.follows = "nixpkgs";
    deploy-rs.url = "github:serokell/deploy-rs";
    deploy-rs.inputs.nixpkgs.follows = "nixpkgs";
    simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/master";
    emacs-overlay.url = "gitlab:nix-community/emacs-overlay";

    uplcg.url = "git+https://stuebinm.eu/git/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;
    sfz.url = "github:weihanglo/sfz";
    sfz.flake = false;
    almanac.url = "git+https://stuebinm.eu/git/almanac";
    almanac.flake = false;
    feeds.url = "path:/home/stuebinm/nonpublic.nix";
    feeds.flake = false;
    isabelle-utils.url = "git+https://stuebinm.eu/git/isabelle-utils";
    isabelle-utils.flake = false;

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

    freiraum.url = "git+https://git.infra4future.de/stuebinm/22f3-roomplans?ref=network";
    freiraum.flake = false;
  };

  outputs = { self, nixpkgs, deploy-rs, ... }@inputs:
  let
    mkConfig = imports: config:
    nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [ config ] ++ imports;

      specialArgs = { inherit inputs; };
    };
    mkServer = mkConfig [ ./common/headless.nix ];
    mkDesktop = mkConfig [ ./common/desktop.nix ];
    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;
      surltesh-echer = mkDesktop ./surltesh-echer/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;
	      };
      };
    };

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

    homeConfigurations =
      let home = root: inputs.home-manager.lib.homeManagerConfiguration rec {
            pkgs = nixpkgs.legacyPackages.x86_64-linux;
            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;
  };
}