diff --git a/flake.lock b/flake.lock index f6768cf..4591cc6 100644 --- a/flake.lock +++ b/flake.lock @@ -216,6 +216,22 @@ } }, "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_5": { "flake": false, "locked": { "lastModified": 1673956053, @@ -231,7 +247,7 @@ "type": "github" } }, - "flake-compat_5": { + "flake-compat_6": { "flake": false, "locked": { "lastModified": 1696426674, @@ -389,6 +405,24 @@ } }, "flake-utils_6": { + "inputs": { + "systems": "systems_6" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_7": { "inputs": { "systems": [ "stylix", @@ -409,9 +443,9 @@ "type": "github" } }, - "flake-utils_7": { + "flake-utils_8": { "inputs": { - "systems": "systems_7" + "systems": "systems_8" }, "locked": { "lastModified": 1710146030, @@ -427,9 +461,9 @@ "type": "github" } }, - "flake-utils_8": { + "flake-utils_9": { "inputs": { - "systems": "systems_8" + "systems": "systems_9" }, "locked": { "lastModified": 1705309234, @@ -821,6 +855,26 @@ "type": "github" } }, + "nixos-wsl": { + "inputs": { + "flake-compat": "flake-compat_4", + "flake-utils": "flake-utils_6", + "nixpkgs": "nixpkgs_8" + }, + "locked": { + "lastModified": 1729300178, + "narHash": "sha256-mkAPu2o5u7F/glAAfBzDji726iL1u2pm2fyN1SPWRQk=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "42c23a6d5a2a1cbfd3fd137a7ff3d47c6d718033", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NixOS-WSL", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1725194671, @@ -931,6 +985,22 @@ } }, "nixpkgs_10": { + "locked": { + "lastModified": 1723415338, + "narHash": "sha256-K/BVeDLkpswRSBh3APxc2gBNVFEMXGpnkuQz666FiTM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6e8760f7f7121128e2037db44915a4a5450b6e67", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { "locked": { "lastModified": 1717696253, "narHash": "sha256-1+ua0ggXlYYPLTmMl3YeYYsBXDSCqT+Gw3u6l4gvMhA=", @@ -1041,32 +1111,32 @@ }, "nixpkgs_8": { "locked": { - "lastModified": 1725062077, - "narHash": "sha256-ARdb2SNoV+zAN80CXeweNm3FZ8NWLmVna7mGKWVONeE=", + "lastModified": 1728740863, + "narHash": "sha256-u+rxA79a0lyhG+u+oPBRtTDtzz8kvkc9a6SWSt9ekVc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "be55bcada114b8e0385544b15cc4bc2148046aee", + "rev": "a3f9ad65a0bf298ed5847629a57808b97e6e8077", "type": "github" }, "original": { "owner": "NixOS", - "ref": "release-24.05", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_9": { "locked": { - "lastModified": 1723415338, - "narHash": "sha256-K/BVeDLkpswRSBh3APxc2gBNVFEMXGpnkuQz666FiTM=", + "lastModified": 1725062077, + "narHash": "sha256-ARdb2SNoV+zAN80CXeweNm3FZ8NWLmVna7mGKWVONeE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6e8760f7f7121128e2037db44915a4a5450b6e67", + "rev": "be55bcada114b8e0385544b15cc4bc2148046aee", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "release-24.05", "repo": "nixpkgs", "type": "github" } @@ -1086,7 +1156,8 @@ "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", "nixd": "nixd", - "nixpkgs": "nixpkgs_8", + "nixos-wsl": "nixos-wsl", + "nixpkgs": "nixpkgs_9", "nixpkgs-master": "nixpkgs-master", "stylix": "stylix", "zls": "zls_2" @@ -1118,12 +1189,12 @@ "base16-kitty": "base16-kitty", "base16-tmux": "base16-tmux", "base16-vim": "base16-vim", - "flake-compat": "flake-compat_4", - "flake-utils": "flake-utils_6", + "flake-compat": "flake-compat_5", + "flake-utils": "flake-utils_7", "gnome-shell": "gnome-shell", "home-manager": "home-manager_2", - "nixpkgs": "nixpkgs_9", - "systems": "systems_6" + "nixpkgs": "nixpkgs_10", + "systems": "systems_7" }, "locked": { "lastModified": 1724702977, @@ -1259,6 +1330,21 @@ "type": "github" } }, + "systems_9": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "zig": { "inputs": { "flake-compat": [ @@ -1310,8 +1396,8 @@ }, "zig-overlay_2": { "inputs": { - "flake-compat": "flake-compat_5", - "flake-utils": "flake-utils_8", + "flake-compat": "flake-compat_6", + "flake-utils": "flake-utils_9", "nixpkgs": [ "zls", "nixpkgs" @@ -1359,10 +1445,10 @@ }, "zls_2": { "inputs": { - "flake-utils": "flake-utils_7", + "flake-utils": "flake-utils_8", "gitignore": "gitignore_3", "langref": "langref_2", - "nixpkgs": "nixpkgs_10", + "nixpkgs": "nixpkgs_11", "zig-overlay": "zig-overlay_2" }, "locked": { diff --git a/flake.nix b/flake.nix index 0b048b7..3d869b8 100644 --- a/flake.nix +++ b/flake.nix @@ -11,8 +11,6 @@ parts = import ./parts; in { - debug = true; - imports = [ (import "${flake-parts}/all-modules.nix") ] ++ builtins.attrValues parts; systems = [ @@ -69,6 +67,7 @@ nixpkgs.url = "github:NixOS/nixpkgs/release-24.05"; stylix.url = "github:danth/stylix"; zls.url = "github:zigtools/zls/0.13.0"; + nixos-wsl.url = "github:nix-community/NixOS-WSL"; #-------------------------------------------------------- # Homebrew dependencies for Darwin diff --git a/modules/by-name/ca/caches/common-module.nix b/modules/by-name/ca/caches/common-module.nix new file mode 100644 index 0000000..f9f1e6a --- /dev/null +++ b/modules/by-name/ca/caches/common-module.nix @@ -0,0 +1,45 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; +let + cfg = config.caches; +in +{ + config.caches = + let + cacheConfig = importJSON ./caches.json; + + cachixCaches = map ( + { name, publicKey }: + { + name = "https://${name}.cachix.org"; + inherit publicKey; + } + ) cacheConfig.cachix; + in + mkDefault (cachixCaches ++ cacheConfig.nix); + + options.caches = + with types; + mkOption { + type = listOf (submodule { + options = { + name = mkOption { type = str; }; + publicKey = mkOption { type = str; }; + }; + }); + }; + + config = { + environment.systemPackages = [ pkgs.cachix ]; + + nix.settings = { + trusted-substituters = map ({ name, ... }: name) cfg; + trusted-public-keys = map ({ publicKey, ... }: publicKey) cfg; + }; + }; +} diff --git a/modules/by-name/ca/caches/darwin-module.nix b/modules/by-name/ca/caches/darwin-module.nix index 201cf81..e3b0e08 100644 --- a/modules/by-name/ca/caches/darwin-module.nix +++ b/modules/by-name/ca/caches/darwin-module.nix @@ -1,43 +1 @@ -{ - pkgs, - lib, - config, - ... -}: -with lib; -let - cfg = config.caches; -in -{ - config.caches = - let - cacheConfig = importJSON ./caches.json; - - cachixCaches = map ( - { name, publicKey }: - { - name = "https://${name}.cachix.org"; - inherit publicKey; - } - ) cacheConfig.cachix; - in - mkDefault (cachixCaches ++ cacheConfig.nix); - - options.caches = - with types; - mkOption { - type = listOf (submodule { - options = { - name = mkOption { type = str; }; - publicKey = mkOption { type = str; }; - }; - }); - }; - - config.nix.settings = { - trusted-substituters = map ({ name, ... }: name) cfg; - trusted-public-keys = map ({ publicKey, ... }: publicKey) cfg; - }; - - config.environment.systemPackages = [ pkgs.cachix ]; -} +{ imports = [ ./common-module.nix ]; } diff --git a/modules/by-name/ca/caches/nixos-module.nix b/modules/by-name/ca/caches/nixos-module.nix new file mode 100644 index 0000000..e3b0e08 --- /dev/null +++ b/modules/by-name/ca/caches/nixos-module.nix @@ -0,0 +1 @@ +{ imports = [ ./common-module.nix ]; } diff --git a/modules/by-name/ni/nix/common-module.nix b/modules/by-name/ni/nix/common-module.nix new file mode 100644 index 0000000..4cebaed --- /dev/null +++ b/modules/by-name/ni/nix/common-module.nix @@ -0,0 +1,29 @@ +{ config, lib, ... }: +{ + nix = { + # Add inputs to path for channel compatibility + nixPath = lib.mapAttrsToList (flake: _: "${flake}=flake:${flake}") config.nix.registry; + + settings = { + trusted-users = [ "@admin" ]; + + experimental-features = [ + "nix-command" + "flakes" + "auto-allocate-uids" + ]; + + sandbox = false; + cores = 0; + max-jobs = "auto"; + auto-allocate-uids = true; + keep-outputs = true; + keep-derivations = true; + }; + + gc = { + automatic = true; + options = "--delete-older-than 30d"; + }; + }; +} diff --git a/modules/by-name/ni/nix/darwin-module.nix b/modules/by-name/ni/nix/darwin-module.nix index 67db1e9..b2303ef 100644 --- a/modules/by-name/ni/nix/darwin-module.nix +++ b/modules/by-name/ni/nix/darwin-module.nix @@ -1,54 +1,27 @@ +{ lib, pkgs, ... }: { - config, - lib, - pkgs, - ... -}: -{ + imports = [ ./common-module.nix ]; + nix = { - # Add inputs to path for channel compatibility - nixPath = lib.mapAttrsToList (flake: _: "${flake}=flake:${flake}") config.nix.registry; + configureBuildUsers = true; settings = { - trusted-users = [ "@admin" ]; - # FIXME: https://github.com/NixOS/nix/issues/7273 auto-optimise-store = false; - experimental-features = [ - "nix-command" - "flakes" - "auto-allocate-uids" - ]; - extra-platforms = lib.mkIf (pkgs.system == "aarch64-darwin") [ "x86_64-darwin" "aarch64-darwin" ]; - - sandbox = false; - cores = 0; - max-jobs = "auto"; - auto-allocate-uids = true; - keep-outputs = true; - keep-derivations = true; }; - gc = { - automatic = true; - - interval = { - Weekday = 0; - Hour = 0; - Minute = 0; - }; - - options = "--delete-older-than 30d"; + gc.interval = { + Weekday = 0; + Hour = 0; + Minute = 0; }; optimise.automatic = true; - - configureBuildUsers = true; }; services.nix-daemon = { diff --git a/modules/by-name/ni/nix/nixos-module.nix b/modules/by-name/ni/nix/nixos-module.nix new file mode 100644 index 0000000..e2aaaae --- /dev/null +++ b/modules/by-name/ni/nix/nixos-module.nix @@ -0,0 +1,9 @@ +{ + imports = [ ./common-module.nix ]; + + nix = { + settings.auto-optimise-store = true; + channel.enable = false; + gc.dates = "weekly"; + }; +} diff --git a/systems/darwin/fixture.nix b/systems/darwin/fixture.nix index f194eee..6a224d3 100644 --- a/systems/darwin/fixture.nix +++ b/systems/darwin/fixture.nix @@ -21,7 +21,10 @@ in inputs.nix-homebrew.darwinModules.nix-homebrew { system.configurationRevision = lib.mkDefault (self.shortRev or self.dirtyShortRev); + nix-homebrew.user = "remi"; + + nix.registry.nixpkgs.flake = inputs.nixpkgs; } ]; }; diff --git a/systems/nixos/default.nix b/systems/nixos/default.nix index 27c906c..7358179 100644 --- a/systems/nixos/default.nix +++ b/systems/nixos/default.nix @@ -1 +1,7 @@ -{ imports = [ ./vm-fixture ]; } +{ + imports = [ + ./fixture + ./vmware-fixture + ./wsl-fixture + ]; +} diff --git a/systems/nixos/fixture/default.nix b/systems/nixos/fixture/default.nix new file mode 100644 index 0000000..f5c5ec7 --- /dev/null +++ b/systems/nixos/fixture/default.nix @@ -0,0 +1,39 @@ +{ + lib, + withSystem, + inputs, + ... +}: +let + system = "aarch64-linux"; + + sharedNixOSModules = (import ../../../modules/top-level/all-modules.nix { inherit lib; }).nixos; +in +{ + flake.nixosConfigurations.fixture = inputs.nixpkgs.lib.nixosSystem { + inherit system; + + pkgs = withSystem system ({ pkgs, ... }: pkgs); + + modules = (builtins.attrValues sharedNixOSModules) ++ [ + inputs.disko.nixosModules.default + ./modules/hardware.nix + ( + { modulesPath, ... }: + { + imports = [ (modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix") ]; + + system = { + stateVersion = "24.05"; + configurationRevision = lib.mkDefault (inputs.self.shortRev or inputs.self.dirtyShortRev); + }; + + time.timeZone = "America/Toronto"; + + # This is a VM, it doesn't need to require password + security.sudo.wheelNeedsPassword = false; + } + ) + ]; + }; +} diff --git a/systems/nixos/fixture/modules/hardware.nix b/systems/nixos/fixture/modules/hardware.nix new file mode 100644 index 0000000..40b85f5 --- /dev/null +++ b/systems/nixos/fixture/modules/hardware.nix @@ -0,0 +1,84 @@ +{ pkgs, lib, ... }: +{ + boot = { + kernelPackages = pkgs.linuxPackages_latest; + + loader = { + efi.canTouchEfiVariables = true; + systemd-boot.enable = lib.mkDefault true; + }; + }; + + disko.devices.disk.main = { + type = "disk"; + + content = { + type = "gpt"; + + partitions = { + ESP = { + priority = 1; + name = "ESP"; + start = "1M"; + end = "128M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + + root = { + size = "100%"; + priority = 2; + + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + mountpoint = "/partition-root"; + + subvolumes = { + "root" = { + mountpoint = "/"; + }; + + "home" = { + mountOptions = [ "compress=zstd" ]; + mountpoint = "/home"; + }; + + "nix" = { + mountOptions = [ + "compress=zstd" + "noatime" + ]; + mountpoint = "/nix"; + }; + + "swap" = { + mountpoint = "/.swapvol"; + + swap = { + swapfile.size = "20M"; + swapfile2.size = "20M"; + swapfile2.path = "rel-path"; + }; + }; + }; + + swap = { + swapfile = { + size = "20M"; + }; + swapfile1 = { + size = "20M"; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/systems/nixos/vm-fixture/default.nix b/systems/nixos/vm-fixture/default.nix deleted file mode 100644 index 1612c1b..0000000 --- a/systems/nixos/vm-fixture/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ - lib, - withSystem, - inputs, - ... -}: -let - system = "aarch64-linux"; - - sharedNixOSModules = (import ../../../modules/top-level/all-modules.nix { inherit lib; }).nixos; -in -{ - flake.nixosConfigurations.vm-fixture = inputs.nixpkgs.lib.nixosSystem { - inherit system; - - pkgs = withSystem system ({ pkgs, ... }: pkgs); - - modules = (builtins.attrValues sharedNixOSModules) ++ [ - inputs.disko.nixosModules.default - ./modules/hardware.nix - ./modules/vmware-guest.nix - { - system = { - stateVersion = "24.05"; - configurationRevision = lib.mkDefault (inputs.self.shortRev or inputs.self.dirtyShortRev); - }; - - time.timeZone = "America/Toronto"; - - # This is a VM, it doesn't need to require password - security.sudo.wheelNeedsPassword = false; - } - ]; - }; -} diff --git a/systems/nixos/vmware-fixture/default.nix b/systems/nixos/vmware-fixture/default.nix new file mode 100644 index 0000000..e81b121 --- /dev/null +++ b/systems/nixos/vmware-fixture/default.nix @@ -0,0 +1,6 @@ +{ config, ... }: +{ + flake.nixosConfigurations.vmware-fixture = config.flake.nixosConfigurations.fixture.extendModules { + modules = [ ./modules/hardware.nix ]; + }; +} diff --git a/systems/nixos/vmware-fixture/modules/hardware.nix b/systems/nixos/vmware-fixture/modules/hardware.nix new file mode 100644 index 0000000..ec62821 --- /dev/null +++ b/systems/nixos/vmware-fixture/modules/hardware.nix @@ -0,0 +1,14 @@ +{ + boot = { + initrd.availableKernelModules = [ + "xhci_pci" + "nvme" + "sr_mod" + ]; + + # VMWare errors on boot if this is not "0" + loader.systemd-boot.consoleMode = "0"; + }; + + disko.devices.disk.main.device = "/dev/disk/nvme0n1"; +} diff --git a/systems/nixos/wsl-fixture/default.nix b/systems/nixos/wsl-fixture/default.nix new file mode 100644 index 0000000..cbfe427 --- /dev/null +++ b/systems/nixos/wsl-fixture/default.nix @@ -0,0 +1,16 @@ +{ config, inputs, ... }: +{ + flake.nixosConfigurations.wsl-fixture = config.flake.nixosConfigurations.fixture.extendModules { + modules = [ + inputs.nixos-wsl.nixosModules.default + { + wsl = { + enable = true; + defaultUser = "remi"; + }; + + boot.loader.systemd-boot.enable = false; + } + ]; + }; +} diff --git a/systems/nixos/vm-fixture/modules/hardware.nix b/systems/nixos/wsl-fixture/modules/hardware.nix similarity index 100% rename from systems/nixos/vm-fixture/modules/hardware.nix rename to systems/nixos/wsl-fixture/modules/hardware.nix diff --git a/systems/nixos/vm-fixture/modules/vmware-guest.nix b/systems/nixos/wsl-fixture/modules/vmware-guest.nix similarity index 100% rename from systems/nixos/vm-fixture/modules/vmware-guest.nix rename to systems/nixos/wsl-fixture/modules/vmware-guest.nix diff --git a/users/remi/home/default.nix b/users/remi/home/default.nix index 802dc72..1a6d579 100644 --- a/users/remi/home/default.nix +++ b/users/remi/home/default.nix @@ -8,9 +8,11 @@ let userHomeModules = (import ../modules/top-level/all-modules.nix { inherit lib; }).home; sharedHomemodules = (import ../../../modules/top-level/all-modules.nix { inherit lib; }).home; + + username = "remi"; in { - flake.homeManagerConfigurations.remi = lib.genAttrs config.systems ( + flake.homeManagerConfigurations.${username} = lib.genAttrs config.systems ( system: inputs.home-manager.lib.homeManagerConfiguration { pkgs = withSystem system ({ pkgs, ... }: pkgs); @@ -22,10 +24,14 @@ in ( { config, ... }: { - username = "remi"; + inherit username; + + email = "mail@remigelin.as"; + fullName = "Remi Gelinas"; home = { - username = "remi"; + inherit username; + homeDirectory = "/home/${config.username}"; stateVersion = "24.05"; };