linux-hardened/flake.nix

75 lines
1.9 KiB
Nix
Raw Normal View History

2024-07-31 11:00:49 +02:00
{
inputs = {
2024-07-31 13:21:20 +02:00
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
2024-07-31 11:00:49 +02:00
};
nixConfig = {
extra-substituters = [ "https://cache.kyouma.net" ];
extra-trusted-public-keys = [ "cache.kyouma.net:Frjwu4q1rnwE/MnSTmX9yx86GNA/z3p/oElGvucLiZg=" ];
};
outputs = { self, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
eachSystem = lib.genAttrs [ "x86_64-linux" ];
2024-07-31 13:27:34 +02:00
legacyPackages = eachSystem (system: import nixpkgs { inherit system; });
2024-07-31 11:00:49 +02:00
2024-07-31 13:27:34 +02:00
linux-hardened = pkgs: arch: configfile:
2024-07-31 11:00:49 +02:00
let
2024-07-31 17:31:35 +02:00
inherit (pkgs) linuxKernel fetchFromGitHub gccStdenv;
2024-07-31 11:00:49 +02:00
2024-07-31 13:27:34 +02:00
kernel = linuxKernel.manualConfig rec {
2024-07-31 11:00:49 +02:00
pname = "linux-hardened";
2024-07-31 11:07:12 +02:00
version = "6.10.2-hardened1";
2024-07-31 11:00:49 +02:00
2024-07-31 13:27:34 +02:00
src = fetchFromGitHub {
2024-07-31 11:00:49 +02:00
owner = "anthraxx";
repo = pname;
rev = "v${version}";
2024-07-31 11:07:12 +02:00
hash = "sha256-a9kxt09pQjUJUsdqaIMyA7Us6sxueaacetWKv59Xy3s=";
2024-07-31 11:00:49 +02:00
};
2024-07-31 17:31:35 +02:00
stdenv = gccStdenv;
2024-07-31 11:00:49 +02:00
2024-07-31 17:31:35 +02:00
extraMakeFlags = [ "KCFLAGS=-march=${arch}" ];
2024-07-31 11:00:49 +02:00
isHardened = true;
inherit configfile features;
};
features = { efiBootStub = true; };
in kernel.overrideAttrs (base: {
2024-07-31 13:27:34 +02:00
passthru = base.passthru // { inherit features; };
2024-07-31 11:00:49 +02:00
});
in {
2024-07-31 13:27:34 +02:00
packages.x86_64-linux =
let
pkgs = legacyPackages.x86_64-linux;
in {
qemu-virtio =
linux-hardened pkgs "x86-64-v3" ./x86-64/qemu-virtio;
thinkpad-x1-extreme-gen5 =
linux-hardened pkgs "alderlake" ./x86-64/thinkpad-x1-extreme-gen5;
};
2024-07-31 11:00:49 +02:00
2024-07-31 13:27:34 +02:00
devShells.x86_64-linux =
2024-07-31 11:00:49 +02:00
let
2024-07-31 13:27:34 +02:00
pkgs = legacyPackages.x86_64-linux;
mkShell = packages: pkgs.mkShell {
inherit packages;
shellHook = ''
exec $SHELL
'';
};
in {
default = mkShell
(with pkgs; self.packages.x86_64-linux.qemu-virtio.nativeBuildInputs ++ [ ncurses pkg-config ]);
};
2024-07-31 11:00:49 +02:00
2024-07-31 13:27:34 +02:00
hydraJobs = {
kernel = self.packages;
shell = self.devShells;
};
2024-07-31 11:00:49 +02:00
};
}