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" "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": { "root": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"riscv-overlay": "riscv-overlay"
} }
} }
}, },

View file

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

View file

@ -1,5 +1,10 @@
{lib, ...}: { {
nixos-config,
lib,
...
}: {
imports = [ imports = [
nixos-config.nixosModules.default
./hostName.nix ./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 = [ imports = [
nixos-config.nixosModules.containers-autoconfig nixos-config.nixosModules.default
]; ];
autoContainers = ["default"]; autoContainers = ["default"];
}; };