summary refs log tree commit diff
path: root/security.nix
AgeCommit message (Expand)Author
2024-11-13Add corsac SSH key and remove redundant keysMel
2024-10-26Glued together corsac configurationMel
='#n26'>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
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";

    lix-module = {
      url = "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0-3.tar.gz";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    home-manager = {
      url = "github:nix-community/home-manager/release-25.05";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nixos-apple-silicon = {
      url = "github:nix-community/nixos-apple-silicon";
      inputs.nixpkgs.follows = "nixpkgs-unstable";
    };

    agenix = {
      url = "github:ryantm/agenix";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.home-manager.follows = "home-manager";
    };

    nix-vscode-extensions = {
      url = "github:nix-community/nix-vscode-extensions";
      inputs.nixpkgs.follows = "nixpkgs-unstable";
    };

    nixpkgs-esp-dev = {
      url = "github:mirrexagon/nixpkgs-esp-dev";
      inputs.nixpkgs.follows = "nixpkgs-unstable";
    };

    flake-compat.url = "github:edolstra/flake-compat";
  };

  outputs =
    inputs@{
      self,
      nixpkgs,
      nixpkgs-unstable,
      lix-module,
      nixos-apple-silicon,
      agenix,
      home-manager,
      nix-vscode-extensions,
      nixpkgs-esp-dev,
      ...
    }:
    let
      systems = {
        x86 = "x86_64-linux";
        arm = "aarch64-linux";
      };

      machines = with systems; [
        {
          name = "graphite";
          system = x86;
        }
        {
          name = "moissanite";
          system = arm;
        }
        {
          name = "bismuth";
          system = x86;
        }
      ];

      overlays = [
        lix-module.overlays.default
        nixos-apple-silicon.overlays.default # unused on non-asahi machines
        agenix.overlays.default
        nix-vscode-extensions.overlays.default
        nixpkgs-esp-dev.overlays.default
        (import ./overlay.nix)
      ];

      packageSetsForSystem =
        system:
        let
          commonPkgsInputs = {
            inherit system;
            config = import ./config.nix;
          };
        in
        rec {
          pkgs = import nixpkgs (commonPkgsInputs // { inherit overlays; });

          unstablePkgs = import nixpkgs-unstable commonPkgsInputs;

          auxiliaryPkgs = import ./pkgs {
            inherit
              pkgs
              unstablePkgs
              nixpkgs
              nixpkgs-unstable
              ;
          };
        };

      inherit (nixpkgs) lib;
    in
    {
      nixosConfigurations = lib.mergeAttrsList (
        map (
          machine:
          let
            packageSets = packageSetsForSystem machine.system;

            specialArgs = inputs // packageSets // { me = machine; };
          in
          {
            ${machine.name} = lib.nixosSystem {
              inherit (machine) system;
              inherit specialArgs;

              modules = [
                ./machines/${machine.name}

                home-manager.nixosModules.home-manager
                {
                  home-manager.useGlobalPkgs = true;
                  home-manager.useUserPackages = true;
                  home-manager.backupFileExtension = "hm-backup";
                  home-manager.extraSpecialArgs = specialArgs;
                  home-manager.users.mel = import ./machines/${machine.name}/home.nix;
                }

                lix-module.nixosModules.default
                agenix.nixosModules.default
              ];
            };
          }
        ) machines
      );

      # compatibility wrapper for nixos-option
      legacyPackages = lib.genAttrs (lib.attrValues systems) (
        system:
        let
          packageSets = packageSetsForSystem system;
        in
        with packageSets;
        pkgs.recurseIntoAttrs pkgs
      );
    };
}