add riscv64 support
Some checks failed
Hydra nixosConfigurations.container-default-riscv64-linux Hydra build #22024 of nixos-config:pr618:nixosConfigurations.container-default-riscv64-linux

This commit is contained in:
Charlotte 🦝 Delenk 2024-10-28 14:58:23 +01:00
parent ef1440ee17
commit 93006f816c
6 changed files with 79 additions and 16 deletions

View file

@ -31,10 +31,31 @@
"type": "github"
}
},
"riscv-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1728672381,
"narHash": "sha256-7zs+Kb4FaClPojFHIv7Wg4YH6B9/PpP2f0o9+5QIA7U=",
"owner": "DarkKirb",
"repo": "riscv-overlay",
"rev": "47b3b0e989ff06046004be0c76d24af9a46a0c29",
"type": "github"
},
"original": {
"owner": "DarkKirb",
"repo": "riscv-overlay",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"riscv-overlay": "riscv-overlay"
}
}
},

View file

@ -6,8 +6,11 @@
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs.url = "github:nixos/nixpkgs";
riscv-overlay = {
url = "github:DarkKirb/riscv-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
@ -21,16 +24,30 @@
nixos-config = self;
inherit inputs;
};
pkgsFor = system:
pkgsFor = system: let
inputs' =
inputs
// {
inherit system;
};
in
import nixpkgs {
inherit system;
overlays = [
(_: _:
inputs
// {
inherit inputs;
})
];
overlays =
[
(_: _:
inputs'
// {
inputs = inputs';
})
]
++ (
if system == "riscv64-linux"
then [
inputs.riscv-overlay.overlays.default
]
else []
);
};
in {
checks.x86_64-linux = nixpkgs.lib.listToAttrs (map (testName: {
@ -39,13 +56,13 @@
}) ["containers-default"]);
nixosModules = {
containers = import ./modules/containers/default.nix;
containers-autoconfig = import ./modules/containers/autoconfig.nix;
default = import ./modules/default.nix;
};
nixosContainers = with nixpkgs.lib; let
containerNames = [
"default"
];
containerArches = ["x86_64-linux" "aarch64-linux"];
containerArches = ["x86_64-linux" "aarch64-linux" "riscv64-linux"];
containers = listToAttrs (flatten (map (system: let
pkgs = pkgsFor system;
in
@ -58,13 +75,15 @@
in
containers;
nixosConfigurations = with nixpkgs.lib; let
mkSystem = args:
mkSystem = args: let
inputs' = inputs // {inherit (args) system;};
in
nixosSystem (args
// {
specialArgs =
args.specialArgs
or {}
// inputs;
// inputs';
});
containers = mapAttrs (_: container:
mkSystem {

View file

@ -1,5 +1,10 @@
{lib, ...}: {
{
nixos-config,
lib,
...
}: {
imports = [
nixos-config.nixosModules.default
./hostName.nix
];

6
modules/default.nix Normal file
View file

@ -0,0 +1,6 @@
{...}: {
imports = [
./riscv.nix
./containers/autoconfig.nix
];
}

12
modules/riscv.nix Normal file
View file

@ -0,0 +1,12 @@
{
system,
riscv-overlay,
...
}: {
nixpkgs.overlays =
if system == "riscv64-linux"
then [
riscv-overlay.overlays.default
]
else [];
}

View file

@ -13,7 +13,7 @@ testers.runNixOSTest {
...
}: {
imports = [
nixos-config.nixosModules.containers-autoconfig
nixos-config.nixosModules.default
];
autoContainers = ["default"];
};