diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0165004 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: Test CI + +on: + push: + branches: + - main + pull_request: + +jobs: + test-flake: + name: "Test flake options" + runs-on: ubuntu-latest + + steps: + - name: Check out the repository + uses: actions/checkout@v7 + + - name: Lix GHA Installer Action + uses: samueldr/lix-gha-installer-action@v2026-06-15 + + - name: Check up flake configuration + run: nix flake check --system x86_64-linux --show-trace diff --git a/checks/biosboot/configuration.nix b/checks/biosboot/configuration.nix new file mode 100644 index 0000000..76f5d89 --- /dev/null +++ b/checks/biosboot/configuration.nix @@ -0,0 +1,31 @@ +{ + pkgs, + ... +}: +{ + networking.hostName = "snow"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + console.useXkbConfig = true; + + users.users."test" = { + isNormalUser = true; + description = "test user"; + extraGroups = [ + "wheel" + "networkmanager" + ]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. + environment.systemPackages = with pkgs; [ + htop + ]; + + system.stateVersion = "26.05"; +} diff --git a/checks/biosboot/default.nix b/checks/biosboot/default.nix new file mode 100644 index 0000000..b023534 --- /dev/null +++ b/checks/biosboot/default.nix @@ -0,0 +1,43 @@ +# source: https://discourse.nixos.org/t/nixostest-with-flake-configurations/11542/5 +{ + inputs, + pkgs, + ... +}: +pkgs.testers.runNixOSTest { + name = "Efiboot config test"; + + nodes.machine = + { ... }: + { + imports = with inputs.self; [ + nixosModules.biosboot + nixosModules.gnome + nixosModules.kernel + nixosModules.metadata + nixosModules.networking + nixosModules.packagemanagers + nixosModules.pipewire + nixosModules.printing + nixosModules.snowflakeos + ./configuration.nix + ]; + }; + + node = { + # since we are using an overlay, we must make pkgs writable + pkgsReadOnly = false; + + specialArgs = { inherit inputs; }; + }; + + # disable only when working on testScript + skipTypeCheck = true; + + testScript = '' + machine.start() + machine.wait_for_unit("multi-user.target") + machine.succeed("uname -a") + machine.succeed("echo Modules succesfully tested") + ''; +} diff --git a/checks/efiboot/configuration.nix b/checks/efiboot/configuration.nix new file mode 100644 index 0000000..76f5d89 --- /dev/null +++ b/checks/efiboot/configuration.nix @@ -0,0 +1,31 @@ +{ + pkgs, + ... +}: +{ + networking.hostName = "snow"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + console.useXkbConfig = true; + + users.users."test" = { + isNormalUser = true; + description = "test user"; + extraGroups = [ + "wheel" + "networkmanager" + ]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. + environment.systemPackages = with pkgs; [ + htop + ]; + + system.stateVersion = "26.05"; +} diff --git a/checks/efiboot/default.nix b/checks/efiboot/default.nix new file mode 100644 index 0000000..3016007 --- /dev/null +++ b/checks/efiboot/default.nix @@ -0,0 +1,43 @@ +# source: https://discourse.nixos.org/t/nixostest-with-flake-configurations/11542/5 +{ + inputs, + pkgs, + ... +}: +pkgs.testers.runNixOSTest { + name = "Efiboot config test"; + + nodes.machine = + { ... }: + { + imports = with inputs.self; [ + nixosModules.efiboot + nixosModules.gnome + nixosModules.kernel + nixosModules.metadata + nixosModules.networking + nixosModules.packagemanagers + nixosModules.pipewire + nixosModules.printing + nixosModules.snowflakeos + ./configuration.nix + ]; + }; + + node = { + # since we are using an overlay, we must make pkgs writable + pkgsReadOnly = false; + + specialArgs = { inherit inputs; }; + }; + + # disable only when working on testScript + skipTypeCheck = true; + + testScript = '' + machine.start() + machine.wait_for_unit("multi-user.target") + machine.succeed("uname -a") + machine.succeed("echo Modules succesfully tested") + ''; +} diff --git a/flake.nix b/flake.nix index 0de920f..6a5e997 100644 --- a/flake.nix +++ b/flake.nix @@ -25,10 +25,19 @@ }; }; - outputs = inputs: + outputs = + inputs: inputs.snowfall-lib.mkFlake { inherit inputs; channels-config.allowUnfree = true; src = ./.; + + # Extra nix flags to set + outputs-builder = channels: { + formatter = channels.nixpkgs.nixfmt-tree; + }; + + # Default shell environment + alias.shells.default = "default"; }; } diff --git a/modules/nixos/biosboot/default.nix b/modules/nixos/biosboot/default.nix index 84ac01a..6c4e1a9 100644 --- a/modules/nixos/biosboot/default.nix +++ b/modules/nixos/biosboot/default.nix @@ -1,4 +1,10 @@ -{ options, config, lib, pkgs, ... }: +{ + options, + config, + lib, + pkgs, + ... +}: with lib; let diff --git a/modules/nixos/efiboot/default.nix b/modules/nixos/efiboot/default.nix index 0118d05..26900a0 100644 --- a/modules/nixos/efiboot/default.nix +++ b/modules/nixos/efiboot/default.nix @@ -1,4 +1,10 @@ -{ options, config, lib, pkgs, ... }: +{ + options, + config, + lib, + pkgs, + ... +}: with lib; let @@ -8,19 +14,21 @@ in { options.modules.efiboot = with types; { bootloader = mkOption { - type = enum [ "grub" "systemd-boot" ]; + type = enum [ + "grub" + "systemd-boot" + ]; default = "systemd-boot"; description = "The kernel to use for booting."; }; }; config = mkMerge [ - (mkIf (cfg.bootloader == "systemd-boot") - { - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.loader.systemd-boot.editor = mkDefault false; - }) + (mkIf (cfg.bootloader == "systemd-boot") { + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.systemd-boot.editor = mkDefault false; + }) (mkIf (cfg.bootloader == "grub") { boot.loader.systemd-boot.enable = false; boot.loader.grub.enable = true; @@ -31,8 +39,9 @@ in { boot.tmp.cleanOnBoot = mkDefault true; # Temporary workaround for "random seed file is world accessible" - fileSystems.${efiSysMountPoint}.options = - mkIf (config.fileSystems.${efiSysMountPoint}.fsType == "vfat") [ "umask=0077" ]; + fileSystems.${efiSysMountPoint}.options = mkIf ( + config.fileSystems.${efiSysMountPoint}.fsType == "vfat" + ) [ "umask=0077" ]; } ]; } diff --git a/modules/nixos/gnome/default.nix b/modules/nixos/gnome/default.nix index acafff9..7eb4ea4 100644 --- a/modules/nixos/gnome/default.nix +++ b/modules/nixos/gnome/default.nix @@ -1,4 +1,10 @@ -{ options, config, lib, pkgs, ... }: +{ + options, + config, + lib, + pkgs, + ... +}: with lib; let @@ -6,10 +12,8 @@ let in { options.modules.gnome = with types; { - gsconnect.enable = - mkEnableOption "Enable KDE Connect integration"; - removeUtils.enable = - mkEnableOption "Remove non-essential GNOME utilities"; + gsconnect.enable = mkEnableOption "Enable KDE Connect integration"; + removeUtils.enable = mkEnableOption "Remove non-essential GNOME utilities"; }; config = { @@ -33,27 +37,30 @@ in enable = true; }; - environment.gnome.excludePackages = mkIf cfg.removeUtils.enable (with pkgs.gnome; [ - baobab - cheese - eog - epiphany - file-roller - gnome-calculator - gnome-calendar - gnome-characters - gnome-clocks - gnome-contacts - gnome-font-viewer - gnome-logs - gnome-maps - gnome-music - gnome-weather - pkgs.gnome-connections - pkgs.gnome-photos - pkgs.gnome-text-editor - simple-scan - totem - ]); + environment.gnome.excludePackages = mkIf cfg.removeUtils.enable ( + with pkgs.gnome; + [ + baobab + cheese + eog + epiphany + file-roller + gnome-calculator + gnome-calendar + gnome-characters + gnome-clocks + gnome-contacts + gnome-font-viewer + gnome-logs + gnome-maps + gnome-music + gnome-weather + pkgs.gnome-connections + pkgs.gnome-photos + pkgs.gnome-text-editor + simple-scan + totem + ] + ); }; } diff --git a/modules/nixos/kernel/default.nix b/modules/nixos/kernel/default.nix index 38e31d8..dacd10c 100644 --- a/modules/nixos/kernel/default.nix +++ b/modules/nixos/kernel/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; { config = { diff --git a/modules/nixos/networking/default.nix b/modules/nixos/networking/default.nix index 388e7d3..9c4ec45 100644 --- a/modules/nixos/networking/default.nix +++ b/modules/nixos/networking/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; { config = { @@ -7,7 +12,10 @@ with lib; # Workaround for https://github.com/NixOS/nixpkgs/issues/180175 systemd.services.NetworkManager-wait-online = { serviceConfig = { - ExecStart = [ "" "${pkgs.networkmanager}/bin/nm-online -q" ]; + ExecStart = [ + "" + "${pkgs.networkmanager}/bin/nm-online -q" + ]; }; }; }; diff --git a/modules/nixos/packagemanagers/default.nix b/modules/nixos/packagemanagers/default.nix index 2d30ce4..4064ccb 100644 --- a/modules/nixos/packagemanagers/default.nix +++ b/modules/nixos/packagemanagers/default.nix @@ -1,4 +1,10 @@ -{ options, config, lib, pkgs, ... }: +{ + options, + config, + lib, + pkgs, + ... +}: with lib; let @@ -6,8 +12,7 @@ let in { options.modules.packagemanagers = with types; { - appimage.enable = - mkEnableOption "Enable AppImage"; + appimage.enable = mkEnableOption "Enable AppImage"; }; config = mkIf cfg.appimage.enable { diff --git a/modules/nixos/pipewire/default.nix b/modules/nixos/pipewire/default.nix index 6aa1aa9..1b1a2aa 100644 --- a/modules/nixos/pipewire/default.nix +++ b/modules/nixos/pipewire/default.nix @@ -1,4 +1,10 @@ -{ options, config, lib, pkgs, ... }: +{ + options, + config, + lib, + pkgs, + ... +}: with lib; let diff --git a/modules/nixos/snowflakeos/default.nix b/modules/nixos/snowflakeos/default.nix index 954d3a8..a0a766d 100644 --- a/modules/nixos/snowflakeos/default.nix +++ b/modules/nixos/snowflakeos/default.nix @@ -1,4 +1,12 @@ -{ options, config, lib, pkgs, inputs, system, ... }: +{ + options, + config, + lib, + pkgs, + inputs, + system, + ... +}: with lib; let @@ -37,17 +45,17 @@ in config = mkMerge [ (mkIf cfg.nixSoftwareCenter.enable { environment.systemPackages = with inputs; [ - nix-software-center.packages.${system}.nix-software-center + nix-software-center.packages.${pkgs.stdenv.hostPlatform.system}.nix-software-center ]; }) (mkIf cfg.nixosConfEditor.enable { environment.systemPackages = with inputs; [ - nixos-conf-editor.packages.${system}.nixos-conf-editor + nixos-conf-editor.packages.${pkgs.stdenv.hostPlatform.system}.nixos-conf-editor ]; }) (mkIf cfg.snowflakeosModuleManager.enable { environment.systemPackages = with inputs; [ - snowflakeos-module-manager.packages.${system}.snowflakeos-module-manager + snowflakeos-module-manager.packages.${pkgs.stdenv.hostPlatform.system}.snowflakeos-module-manager ]; }) (mkIf cfg.binaryCompat.enable { @@ -80,7 +88,7 @@ in snowflakeos.gnome.enable = mkDefault true; environment.systemPackages = with inputs; [ - snow.packages.${system}.snow + snow.packages.${pkgs.stdenv.hostPlatform.system}.snow pkgs.git # For rebuiling with github flakes ]; @@ -93,27 +101,42 @@ in }; # Reasonable Defaults - nix = - { - settings = { - experimental-features = [ "nix-command" "flakes" ]; - substituters = [ "https://snowflakeos.cachix.org/" ]; - trusted-public-keys = [ - "snowflakeos.cachix.org-1:gXb32BL86r9bw1kBiw9AJuIkqN49xBvPd1ZW8YlqO70=" - ]; - } // (mapAttrsRecursive (_: mkDefault) { - connect-timeout = 5; - log-lines = 25; - min-free = 128000000; - max-free = 1000000000; - fallback = true; - warn-dirty = false; - auto-optimise-store = true; - }); - } // (mapAttrsRecursive (_: mkDefault) { - linkInputs = true; - generateNixPathFromInputs = true; - generateRegistryFromInputs = true; + nix = { + settings = { + experimental-features = lib.mkDefault [ + "nix-command" + "flakes" + ]; + substituters = [ "https://snowflakeos.cachix.org/" ]; + trusted-public-keys = [ + "snowflakeos.cachix.org-1:gXb32BL86r9bw1kBiw9AJuIkqN49xBvPd1ZW8YlqO70=" + ]; + + # trusted-users = + # builtins.attrValues config.users.users + # |> builtins.filter (attr: attr.isNormalUser) + # |> map (u: u.name); + } + // (lib.mapAttrsRecursive (_: lib.mkDefault) { + connect-timeout = 5; + log-lines = 25; + min-free = 128000000; + max-free = 1000000000; + fallback = true; + warn-dirty = false; + auto-optimise-store = true; + }); + } + // (lib.mapAttrsRecursive (_: lib.mkDefault) { + # flake-plus-utils provided options + # linkInputs = true; + # generateNixPathFromInputs = true; + # generateRegistryFromInputs = true; + + # Manually implemented nixPath and registry + # Because flake-utils-plus options arent' working + registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + nixPath = [ "/etc/nix/inputs" ]; }); }) ]; diff --git a/modules/nixos/snowflakeos/gnome.nix b/modules/nixos/snowflakeos/gnome.nix index 7f8617e..7f54746 100644 --- a/modules/nixos/snowflakeos/gnome.nix +++ b/modules/nixos/snowflakeos/gnome.nix @@ -1,4 +1,10 @@ -{ lib, config, options, pkgs, ... }: +{ + lib, + config, + options, + pkgs, + ... +}: let nixos-background-info = pkgs.stdenv.mkDerivation { name = "nixos-background-info"; }; snowflakeos-background-info = pkgs.writeTextFile rec { diff --git a/modules/nixos/snowflakeos/graphical.nix b/modules/nixos/snowflakeos/graphical.nix index 81a3dfa..c263446 100644 --- a/modules/nixos/snowflakeos/graphical.nix +++ b/modules/nixos/snowflakeos/graphical.nix @@ -1,4 +1,10 @@ -{ lib, config, options, pkgs, ... }: +{ + lib, + config, + options, + pkgs, + ... +}: with lib; { diff --git a/modules/nixos/snowflakeos/hardware.nix b/modules/nixos/snowflakeos/hardware.nix index 707b049..2dccb75 100644 --- a/modules/nixos/snowflakeos/hardware.nix +++ b/modules/nixos/snowflakeos/hardware.nix @@ -1,4 +1,10 @@ -{ lib, config, options, pkgs, ... }: +{ + lib, + config, + options, + pkgs, + ... +}: with lib; let @@ -11,8 +17,7 @@ let ''; in { - config = mkIf (config.hardware.nvidia.prime.offload.enable && config.snowflakeos.graphical.enable) - { - environment.systemPackages = [ nvidia-offload ]; - }; + config = mkIf (config.hardware.nvidia.prime.offload.enable && config.snowflakeos.graphical.enable) { + environment.systemPackages = [ nvidia-offload ]; + }; } diff --git a/modules/nixos/snowflakeos/version.nix b/modules/nixos/snowflakeos/version.nix index 0e73720..60de63e 100644 --- a/modules/nixos/snowflakeos/version.nix +++ b/modules/nixos/snowflakeos/version.nix @@ -1,15 +1,20 @@ -{ lib, config, options, pkgs, ... }: +{ + lib, + config, + options, + pkgs, + ... +}: with lib; let cfg = config.system.nixos; needsEscaping = s: null != builtins.match "[a-zA-Z0-9]+" s; escapeIfNeccessary = s: if needsEscaping s then s else ''"${escape [ "\$" "\"" "\\" "\`" ] s}"''; - attrsToText = attrs: - concatStringsSep "\n" - ( - mapAttrsToList (n: v: ''${n}=${escapeIfNeccessary (toString v)}'') attrs - ) + "\n"; + attrsToText = + attrs: + concatStringsSep "\n" (mapAttrsToList (n: v: "${n}=${escapeIfNeccessary (toString v)}") attrs) + + "\n"; osReleaseContents = { NAME = "SnowflakeOS"; ID = "snowflakeos"; diff --git a/packages/nix-software-center/default.nix b/packages/nix-software-center/default.nix index fd812c9..6b099fb 100644 --- a/packages/nix-software-center/default.nix +++ b/packages/nix-software-center/default.nix @@ -1,2 +1 @@ -{ inputs, system }: -inputs.nix-software-center.packages.${system}.nix-software-center +{ inputs, system }: inputs.nix-software-center.packages.${system}.nix-software-center diff --git a/packages/nixos-conf-editor/default.nix b/packages/nixos-conf-editor/default.nix index 97dc048..41c9a29 100644 --- a/packages/nixos-conf-editor/default.nix +++ b/packages/nixos-conf-editor/default.nix @@ -1,2 +1 @@ -{ inputs, system }: -inputs.nixos-conf-editor.packages.${system}.nixos-conf-editor +{ inputs, system }: inputs.nixos-conf-editor.packages.${system}.nixos-conf-editor diff --git a/packages/snow/default.nix b/packages/snow/default.nix index 3266197..f932352 100644 --- a/packages/snow/default.nix +++ b/packages/snow/default.nix @@ -1,2 +1,6 @@ -{ inputs, system }: -inputs.snow.packages.${system}.snow +{ + inputs, + system, + pkgs, +}: +inputs.snow.packages.${pkgs.stdenv.hostPlatform.system}.snow diff --git a/packages/snowflakeos-module-manager/default.nix b/packages/snowflakeos-module-manager/default.nix index a8f5513..49af81d 100644 --- a/packages/snowflakeos-module-manager/default.nix +++ b/packages/snowflakeos-module-manager/default.nix @@ -1,2 +1,2 @@ -{ inputs, system }: -inputs.snowflakeos-module-manager.packages.${system}.snowflakeos-module-manager +{ inputs, system, pkgs }: +inputs.snowflakeos-module-manager.packages.${pkgs.stdenv.hostPlatform.system}.snowflakeos-module-manager diff --git a/shells/default/default.nix b/shells/default/default.nix new file mode 100644 index 0000000..95ba9f7 --- /dev/null +++ b/shells/default/default.nix @@ -0,0 +1,15 @@ +{ + mkShell, + nixd, + statix, + deadnix, + nixfmt, +}: +mkShell { + nativeBuildInputs = [ + nixd + statix + deadnix + nixfmt + ]; +}