diff options
| author | Mel <mel@rnrd.eu> | 2025-07-12 04:00:28 +0200 |
|---|---|---|
| committer | Mel <mel@rnrd.eu> | 2025-07-12 04:00:28 +0200 |
| commit | 4fd56f73360372665dd072adac2a78156d4caf2d (patch) | |
| tree | ce681316938f536ad2309e1711ba3eb40046c8d2 /flake.nix | |
| parent | 90ae56d81617248ed6570dfc7fb67940db6f8450 (diff) | |
| download | minerals-4fd56f73360372665dd072adac2a78156d4caf2d.tar.zst minerals-4fd56f73360372665dd072adac2a78156d4caf2d.zip | |
Setup new M1 MacBook as 'Moissanite' with Asahi Linux
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 107 |
1 files changed, 75 insertions, 32 deletions
diff --git a/flake.nix b/flake.nix index ca3e1c5..c493fcd 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,11 @@ 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"; @@ -38,6 +43,7 @@ nixpkgs, nixpkgs-unstable, lix-module, + nixos-apple-silicon, agenix, home-manager, nix-vscode-extensions, @@ -45,22 +51,37 @@ ... }: let - system = "x86_64-linux"; - - machines = [ - "graphite" - "bismuth" + 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) ]; - packageSets = + packageSetsForSystem = + system: let commonPkgsInputs = { inherit system; @@ -72,38 +93,60 @@ unstablePkgs = import nixpkgs-unstable commonPkgsInputs; - auxiliaryPkgs = import ./pkgs { inherit pkgs unstablePkgs nixpkgs nixpkgs-unstable; }; + auxiliaryPkgs = import ./pkgs { + inherit + pkgs + unstablePkgs + nixpkgs + nixpkgs-unstable + ; + }; }; + inherit (nixpkgs) lib; in { - nixosConfigurations = nixpkgs.lib.genAttrs machines ( - machine: - let - specialArgs = inputs // packageSets // { me = machine; }; - in - nixpkgs.lib.nixosSystem { - inherit system specialArgs; - - modules = [ - ./machines/${machine} - - 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}/home.nix; - } - - lix-module.nixosModules.default - agenix.nixosModules.default - ]; - } + 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.${system} = with packageSets; pkgs.recurseIntoAttrs pkgs; + legacyPackages = lib.genAttrs (lib.attrValues systems) ( + system: + let + packageSets = packageSetsForSystem system; + in + with packageSets; + pkgs.recurseIntoAttrs pkgs + ); }; } |
