about summary refs log tree commit diff
path: root/flake.nix
blob: a595f4fa35a063f57f038a769d20712950a97415 (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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{
  inputs = {
    nixpkgs.url = "git+https://github.com/nixos/nixpkgs?ref=release-24.05";
    nixpkgs-unstable.url = "git+https://github.com/nixos/nixpkgs?ref=nixpkgs-unstable";

    darwin.url = "git+https://github.com/lnl7/nix-darwin";
    darwin.inputs.nixpkgs.follows = "nixpkgs";

    deploy-rs.url = "git+https://github.com/serokell/deploy-rs?ref=master";
    deploy-rs.inputs.nixpkgs.follows = "nixpkgs";

    agenix.url = "git+https://github.com/ryantm/agenix";
    agenix.inputs.nixpkgs.follows = "nixpkgs";

    home-manager.url = "git+https://github.com/nix-community/home-manager?ref=release-24.05";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";

    naersk.url = "git+https://github.com/nix-community/naersk";
    naersk.inputs.nixpkgs.follows = "nixpkgs";

    # hefe-internal.url = "git+ssh://gitea@git.emile.space/hanemile/hefe-internal.git?ref=main";

    # nix registry add flake:mylocalrepo git+file:///path/to/local/repo
    # nix registry list
    # hefe-internal.url = "flake:mylocalrepo";
    # hefe-internal.url = "git+file:///Users/emile/Documents/hefe-internal";
    hefe-internal.url = "git+ssh://git@git.emile.space/hefe-internal";
  };

  outputs = {
    self,
    nixpkgs, nixpkgs-unstable, # general packages
    darwin, # darwin related stuff
    deploy-rs, # deploy the hosts
    agenix, # store secrets crypted using age
    home-manager, # manage my home envs
    naersk, # build rust stuff
    hefe-internal, # internal tooling
    ... }@inputs:
  let
    lib = import ./nix/lib inputs;
    helper = lib.flake-helper;
  in {

    hosts = {
      caladan = {
        system = "aarch64-darwin";
        sshUser = "hydra";
        homeManagerEnable = true;
        description = "macbook air";
      };
      corrino = {
        system = "x86_64-linux";
        ip = "corrino";
        description = "Hetzner AX41 dual 512GB NVME";
        modules = [ hefe-internal.nixosModules.corrino ];
      };
      chusuk = {
        # ip = "chusuk.pinto-pike.ts.net";
        system = "x86_64-linux";
        description = "lenovo t480";
      };
      hacknix = {
        # ip = "hacknix.pinto-pike.ts.net"; # clone repo and deploy within
        system = "x86_64-linux";
        description = "hacking vm";
      };
      mail = {
        # ip = "mail.pinto-pike.ts.net"; # clone repo and deploy within
        system = "x86_64-linux";
        description = "mail server";
      };


      #ecaz = {};

      # gamont = {
      #   description = "pi 2 tfp"
      # };

      #kolhar = {}; # nixos vm on caladan
      #hagal = {}; # apple tv
      
      # DONE
      # lampadas = {
      #   description = "NAS";
      # };
      # DONE
      # lernaeus = {
      #   description = "ryzen 5 5600g";
      # };

      # TBD.
      # palma = {
      #   hostname = "lampadas";
      #   description = "palma bmc";
      # };

      # lankiveil = {
      #   description = "ryzen 5 3600 + RTX A2000";
      # };
      # parmentier = {
      #   hostname = "lankiveil";
      #   description = "parmentier bmc";
      # };


      # TBD
      # poritrin = {
      #   hostname = "lernaeus";
      #   description = "poritrin bmc";
      # };

      #kaitain = {};

      # futher names: https://neoencyclopedia.fandom.com/wiki/List_of_Dune_planets
      # Muritan
      # Naraj
      # Palma
      # Parmentier
      # Poritrin
      # Richese
      # Romo
      # Rossak
      # Sikun
      # Synchrony
      # Tleilax
      # Tupile
      # Zanovar
    };

    nixosConfigurations = helper.mapToNixosConfigurations self.hosts;
    darwinConfigurations = helper.mapToDarwinConfigurations self.hosts;

    overlays = {
      emile = import ./nix/pkgs/overlay.nix;
      default = self.overlays.emile;

      unstable = final: prev: {
        unstable = import nixpkgs-unstable {
          system = "x86_64-linux";
          config.allowUnfree = true;
        };
      };
    };

    deploy.nodes = helper.mapToDeployRsConfiguration self.hosts;
    deploy.autoRollback = true;

    packages =
      nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-darwin" ] (system:
    let
      pkgs = import nixpkgs {
        inherit system;
        overlays = [
          self.overlays.emile

          # some arguments for packages
          (_: _: { inherit naersk; })
        ];
      };
    in {
      inherit (pkgs)
        vokobe
        # emu-riscv
        # emu-mips
        # emu-x86_64
        ;
    });

    hydraJobs = {
      inherit (self) packages;
      nixosConfigurations = helper.buildHosts self.nixosConfigurations;
    };

    templates = {
      # ; nix nix registry add hefe /Users/emile/Documents/hefe
      # ; nix flake init -t hefe#ctf
      ctf = {
        description = "A basic ctf env with pwn, rev, ... tools";
        path = ./nix/templates/ctf;
        welcomeText = ''
          # A basic CTF env
          ## Intended usage
          The intended usage of this flake is...

          ## More info
          - [Rust language](https://www.rust-lang.org/)
          - [Rust on the NixOS Wiki](https://nixos.wiki/wiki/Rust)
          - ...
        '';
      };
    };

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