Files
NixOS-WSL/flake.nix
T
codgician 07121c1c33 ci: add aarch64-linux support for checks, builds, and releases
- Update run_checks.yml to run flake checks on both x86_64-linux and aarch64-linux using matrix strategy
- Update run_build.yml to build tarballs for both architectures using matrix strategy
- Update run_validate.yml to validate both tarballs
- Update run_tests.yml to use the x86_64 tarball artifact
- Update on_release.yml to upload both nixos.wsl and nixos.aarch64.wsl with checksums
- Add aarch64 nixosConfiguration to flake.nix
- Use ubuntu-24.04 for x86 runners and ubuntu-24.04-arm for arm64 runners
2026-02-27 15:26:54 +08:00

117 lines
3.5 KiB
Nix

{
description = "NixOS WSL";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs =
inputs@{ self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = function: lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
in
{
nixosModules.wsl = {
imports = [
./modules
(_: {
wsl.version.rev = lib.mkIf (self ? rev) self.rev;
})
];
};
nixosModules.default = self.nixosModules.wsl;
nixosConfigurations =
let
mkSystem = system: lib.nixosSystem {
inherit system;
modules = [
self.nixosModules.default
({ config, lib, pkgs, ... }: {
# This config is only used until the first nixos-rebuild. For the config installed to /etc/nixos/configuration.nix, see modules/build-tarball.nix
wsl.enable = true;
programs.bash.loginShellInit = "nixos-wsl-welcome";
# When the config is built from a flake, the NIX_PATH entry of nixpkgs is set to its flake version.
# Per default the resulting systems aren't flake-enabled, so rebuilds would fail.
# Note: This does not affect the module being imported into your own flake.
nixpkgs.flake.source = lib.mkForce null;
systemd.tmpfiles.rules =
let
channels = pkgs.runCommand "default-channels" { } ''
mkdir -p $out
ln -s ${pkgs.path} $out/nixos
ln -s ${./.} $out/nixos-wsl
'';
in
[
"L /nix/var/nix/profiles/per-user/root/channels-1-link - - - - ${channels}"
"L /nix/var/nix/profiles/per-user/root/channels - - - - channels-1-link"
];
system.stateVersion = config.system.nixos.release;
})
];
};
in
{
default = mkSystem "x86_64-linux";
aarch64 = mkSystem "aarch64-linux";
};
checks = forAllSystems (
pkgs:
let
args = { inherit inputs; };
in
{
nixpkgs-fmt = pkgs.callPackage ./checks/nixpkgs-fmt.nix args;
nixpkgs-input = pkgs.callPackage ./checks/nixpkgs-input.nix args;
options-doc = pkgs.callPackage ./checks/options-doc.nix args;
rustfmt = pkgs.callPackage ./checks/rustfmt.nix args;
side-effects = pkgs.callPackage ./checks/side-effects.nix args;
username = pkgs.callPackage ./checks/username.nix args;
test-native-utils = self.packages.${pkgs.stdenv.hostPlatform.system}.utils;
}
);
packages = forAllSystems (pkgs: {
utils = pkgs.callPackage ./utils { };
staticUtils = pkgs.pkgsStatic.callPackage ./utils { };
docs = pkgs.callPackage ./docs { };
});
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
nativeBuildInputs = with pkgs; [
cargo
clippy
mdbook
nixpkgs-fmt
powershell
rustc
rustfmt
shfmt
];
};
});
};
}