summaryrefslogtreecommitdiff
path: root/flake.nix
blob: cd44ed50696a34b09bf779cf4917c55b8b2fe0ee (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
{
  inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/25.05";
  inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
  inputs.disko.url = "github:nix-community/disko";
  inputs.disko.inputs.nixpkgs.follows = "nixpkgs-stable";
  inputs.nixos-facter-modules.url = "github:numtide/nixos-facter-modules";
  inputs.sops-nix.url = "github:Mic92/sops-nix";
  inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs-stable";
  inputs.nixos-anywhere.url = "github:nix-community/nixos-anywhere";
  inputs.nixos-anywhere.inputs.nixpkgs.follows = "nixpkgs-stable";

  outputs =
    {
      nixpkgs-stable,
      nixpkgs-unstable,
      disko,
      nixos-facter-modules,
      sops-nix,
      nixos-anywhere,
      ...
    }:
    let
      systems = [
        "x86_64-linux"
        "x86_64-darwin"
        "aarch64-linux"
        "aarch64-darwin"
      ];
    in
    {
      nixosConfigurations.kj-laptop01 = nixpkgs-unstable.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          disko.nixosModules.disko
          ./kj-laptop01/configuration.nix
          nixos-facter-modules.nixosModules.facter
          sops-nix.nixosModules.sops
          {
            config.facter.reportPath = ./kj-laptop01/facter.json;
          }
        ];
      };

      formatter = nixpkgs-stable.lib.genAttrs systems (
        system: nixpkgs-stable.legacyPackages.${system}.nixfmt-tree
      );

      apps = nixpkgs-stable.lib.genAttrs systems (
        system:
        let
          pkgs = nixpkgs-stable.legacyPackages.${system};
          ruby = pkgs.ruby.withPackages (ps: [
            pkgs.rubyPackages.tty-command
          ]);

          nixos-update = pkgs.writeShellApplication  {
            name = "nixos-update";
            runtimeInputs = [
              pkgs.sops
              pkgs.nixos-anywhere
              pkgs.nixos-rebuild-ng
            ];
            text = ''
              exec "${ruby}/bin/ruby" "${./nixos-update.rb}" "$@"
            '';
          };

        in
        {
          nixos-update = {
            type = "app";
            program = "${nixos-update}/bin/nixos-update";
          };
        }
      );
    };
}