Initial import
This commit is contained in:
commit
bcb006544f
8 changed files with 279 additions and 0 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Hidden files
|
||||
.*
|
||||
!.git*
|
||||
|
||||
# Nix
|
||||
/result
|
27
flake.lock
Normal file
27
flake.lock
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1721743106,
|
||||
"narHash": "sha256-adRZhFpBTnHiK3XIELA3IBaApz70HwCYfv7xNrHjebA=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dc14ed91132ee3a26255d01d8fd0c1f5bff27b2f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
67
flake.nix
Normal file
67
flake.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
};
|
||||
|
||||
nixConfig = {
|
||||
extra-substituters = [ "https://cache.kyouma.net" ];
|
||||
extra-trusted-public-keys = [ "cache.kyouma.net:Frjwu4q1rnwE/MnSTmX9yx86GNA/z3p/oElGvucLiZg=" ];
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, ... }@inputs:
|
||||
let
|
||||
inherit (builtins) mapAttrs;
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
platforms = mapAttrs
|
||||
(name: platform: lib.systems.elaborate platform)
|
||||
(import ./platforms.nix);
|
||||
in {
|
||||
lib = { inherit platforms; };
|
||||
overlays.default = import ./overlay.nix inputs;
|
||||
|
||||
nixosModules.default = { ... }: {
|
||||
nixpkgs = {
|
||||
overlays = [ self.overlays.default ];
|
||||
config = {
|
||||
allowUnsupportedSystem = true;
|
||||
replaceStdenv =
|
||||
{ pkgs }: pkgs.idiosyn pkgs.stdenv;
|
||||
replaceCrossStdenv =
|
||||
{ buildPackages, baseStdenv }: buildPackages.idiosyn baseStdenv;
|
||||
};
|
||||
};
|
||||
|
||||
imports = [ ./module.nix ];
|
||||
};
|
||||
|
||||
legacyPackages = mapAttrs (system: platform:
|
||||
import nixpkgs {
|
||||
localSystem = system;
|
||||
crossSystem = platform;
|
||||
overlays = [ self.overlays.default ];
|
||||
config = {
|
||||
allowUnsupportedSystem = true;
|
||||
replaceStdenv =
|
||||
{ pkgs }: pkgs.idiosyn pkgs.stdenv;
|
||||
replaceCrossStdenv =
|
||||
{ buildPackages, baseStdenv }: buildPackages.idiosyn baseStdenv;
|
||||
};
|
||||
}) platforms;
|
||||
|
||||
nixosConfigurations = mapAttrs (system: platform: lib.nixosSystem {
|
||||
modules = [
|
||||
self.nixosModules.default
|
||||
./nixos.nix {
|
||||
nixpkgs.buildPlatform = system;
|
||||
nixpkgs.hostPlatform = platform;
|
||||
}
|
||||
];
|
||||
}) platforms;
|
||||
|
||||
hydraJobs = {
|
||||
stdenv = mapAttrs (system: pkgs: pkgs.stdenv) self.legacyPackages;
|
||||
nixos = mapAttrs (name: host: host.config.system.build.toplevel) self.nixosConfigurations;
|
||||
};
|
||||
};
|
||||
}
|
34
module.nix
Normal file
34
module.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
let
|
||||
inherit (pkgs.stdenv) hostPlatform;
|
||||
locale-archive-stub =
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = "locale-archive-stub";
|
||||
version = "0";
|
||||
|
||||
buildCommand = ''
|
||||
mkdir -p "$out/lib/locale"
|
||||
touch "$out/lib/locale/locale-archive"
|
||||
'';
|
||||
};
|
||||
in {
|
||||
disabledModules = [
|
||||
(modulesPath + "/config/ldso.nix")
|
||||
(modulesPath + "/config/stub-ld.nix")
|
||||
(modulesPath + "/programs/nix-ld.nix")
|
||||
];
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf hostPlatform.isMusl {
|
||||
i18n.glibcLocales = lib.mkDefault locale-archive-stub;
|
||||
i18n.supportedLocales = lib.mkDefault [ ];
|
||||
|
||||
programs.command-not-found.enable = lib.mkDefault false;
|
||||
programs.less.lessopen = lib.mkDefault null;
|
||||
|
||||
security.pam.services.login.updateWtmp = lib.mkForce false;
|
||||
services.nscd.enable = lib.mkForce false;
|
||||
system.nssModules = lib.mkForce [ ];
|
||||
})
|
||||
];
|
||||
}
|
18
nixos.nix
Normal file
18
nixos.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{ pkgs, ... }: {
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
fileSystems."/".label = "nixos";
|
||||
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
services.getty.autologinUser = "nixos";
|
||||
|
||||
users.users.nixos = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ];
|
||||
};
|
||||
|
||||
system.stateVersion = "24.11";
|
||||
|
||||
virtualisation.vmVariant.virtualisation.diskImage = null;
|
||||
}
|
47
overlay.nix
Normal file
47
overlay.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{ nixpkgs, ... }: final: prev:
|
||||
let
|
||||
inherit (final) lib callPackage;
|
||||
|
||||
pkgs = import nixpkgs {
|
||||
localSystem = final.buildPlatform;
|
||||
crossSystem = final.hostPlatform;
|
||||
config = removeAttrs final.config [
|
||||
"replaceStdenv"
|
||||
"replaceCrossStdenv"
|
||||
];
|
||||
};
|
||||
|
||||
idiosyn = import ./stdenv.nix pkgs;
|
||||
|
||||
gentoo-patches = final.fetchgit {
|
||||
url = "https://anongit.gentoo.org/git/repo/gentoo.git";
|
||||
rev = "fa77d52a7ff39464c50707ca024725deab08b534";
|
||||
sparseCheckout = [ "*.patch" ];
|
||||
nonConeMode = true;
|
||||
hash = "sha256-ZTrPeo8TjKSDAUyeJyWq1C8O9EXd9uhClHlphPsFXCA=";
|
||||
};
|
||||
in {
|
||||
inherit idiosyn;
|
||||
|
||||
keyutils = prev.keyutils.overrideAttrs (base: {
|
||||
LDFLAGS = lib.toList base.ldFlags or [ ]
|
||||
++ [ "-Wl,--undefined-version" ];
|
||||
});
|
||||
|
||||
busybox = prev.busybox.overrideAttrs (base: {
|
||||
makeFlags = base.makeFlags or [ ]
|
||||
++ [ "CC=${final.buildPackages.gcc}/bin/${final.stdenv.cc.targetPrefix}cc" ];
|
||||
});
|
||||
|
||||
libgcrypt = prev.libgcrypt.overrideAttrs (base: {
|
||||
configureFlags = base.configureFlags or [ ]
|
||||
++ [ "--disable-jent-support" ];
|
||||
});
|
||||
|
||||
time = prev.time.overrideAttrs (base: {
|
||||
patches = base.patches or [ ]
|
||||
++ lib.optional final.time.stdenv.cc.isClang
|
||||
"${gentoo-patches}/sys-process/time/files/time-1.9-implicit-func-decl-clang.patch";
|
||||
});
|
||||
}
|
||||
|
23
platforms.nix
Normal file
23
platforms.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"x86_64-linux" = {
|
||||
system = "x86_64-linux";
|
||||
#config = "x86_64-unknown-linux-musl";
|
||||
gcc.arch = "x86-64-v3";
|
||||
useLLVM = true;
|
||||
linker = "lld";
|
||||
};
|
||||
"aarch64-linux" = {
|
||||
system = "aarch64-linux";
|
||||
#config = "aarch64-unknown-linux-musl";
|
||||
gcc.arch = "armv8.2-a";
|
||||
useLLVM = true;
|
||||
linker = "lld";
|
||||
};
|
||||
"riscv64-linux" = {
|
||||
system = "aarch64-linux";
|
||||
#config = "riscv64-unknown-linux-musl";
|
||||
gcc.arch = "rv64imafdc_zicsr_zba_zbb";
|
||||
useLLVM = true;
|
||||
linker = "lld";
|
||||
};
|
||||
}
|
57
stdenv.nix
Normal file
57
stdenv.nix
Normal file
|
@ -0,0 +1,57 @@
|
|||
pkgs: stdenv:
|
||||
let
|
||||
inherit (pkgs) addAttrsToDerivation;
|
||||
inherit (pkgs.lib) optionalAttrs optionals toList;
|
||||
inherit (stdenv) buildPlatform hostPlatform;
|
||||
|
||||
cflagsC = [
|
||||
"-pipe" # Prefer pipes over temporary files between stages
|
||||
"-O2" # Safe compiler optimisations
|
||||
# ] ++ optionals buildPlatform.useLLVM [
|
||||
"-flto=thin"
|
||||
];
|
||||
|
||||
cflagsL = [
|
||||
"-pipe"
|
||||
"-fuse-ld=lld"
|
||||
];
|
||||
|
||||
ldflags = [
|
||||
"-O2" # Enable tail merging of strings
|
||||
"--hash-style=gnu" # Produce only DT_GNU_HASH
|
||||
# ] ++ optionals buildPlatform.useLLVM [
|
||||
"--icf=safe" # Fold identical code where safe
|
||||
"--lto-O2"
|
||||
"--pack-dyn-relocs=relr"
|
||||
];
|
||||
|
||||
rustflags = [
|
||||
"-C opt-level=2"
|
||||
"-C linker-flavor=lld"
|
||||
# ] ++ optionals buildPlatform.useLLVM [
|
||||
"-C lto=thin"
|
||||
"-C linker-plugin-lto"
|
||||
] ++ optionals (hostPlatform.isx86_64 && hostPlatform ? gcc.arch) [
|
||||
"-C target-cpu=${hostPlatform.gcc.arch}"
|
||||
] ++ map (flag: "-C link-arg=${flag}") ldflags;
|
||||
|
||||
in addAttrsToDerivation (base: {
|
||||
env = (base.env or { }) // optionalAttrs (!base ? NIX_CFLAGS_COMPILE) {
|
||||
NIX_CFLAGS_COMPILE =
|
||||
toString (toList base.env.NIX_CFLAGS_COMPILE or [ ] ++ cflagsC);
|
||||
} // optionalAttrs (base ? env.NIX_CFLAGS_LINK) {
|
||||
NIX_CFLAGS_LINK =
|
||||
toString (toList base.NIX_CFLAGS_LINK or [ ] ++ cflagsL);
|
||||
} // optionalAttrs (base ? env.NIX_LDFLAGS) {
|
||||
NIX_LDFLAGS =
|
||||
toString (toList base.env.NIX_LDFLAGS or [ ] ++ ldflags);
|
||||
};
|
||||
|
||||
NIX_RUSTFLAGS = toList base.NIX_RUSTFLAGS or [ ] ++ rustflags;
|
||||
} // optionalAttrs (base ? env.NIX_CFLAGS) {
|
||||
NIX_CFLAGS_COMPILE = toList base.NIX_CFLAGS_COMPILE or [ ] ++ cflagsC;
|
||||
} // optionalAttrs (!base ? env.NIX_CFLAGS_LINK) {
|
||||
NIX_CFLAGS_LINK = toList base.NIX_CFLAGS_LINK or [ ] ++ cflagsL;
|
||||
} // optionalAttrs (!base ? env.NIX_LDFLAGS) {
|
||||
NIX_LDFLAGS = toList base.NIX_LDFLAGS or [ ] ++ ldflags;
|
||||
}) stdenv
|
Loading…
Reference in a new issue