style(nixfmt): formatting using nixfmt cli tools

This commit is contained in:
Raphael 2025-10-09 00:09:26 +02:00
parent b804520f4c
commit fbe803b928
No known key found for this signature in database
46 changed files with 2133 additions and 1700 deletions

View file

@ -12,12 +12,20 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
}; };
outputs = { self, nixpkgs, flake-utils, simple-nixos-mailserver, ... }@inputs: outputs =
{
self,
nixpkgs,
flake-utils,
simple-nixos-mailserver,
...
}@inputs:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
config.allowUnfree = true; config.allowUnfree = true;
}; };
in { in
{
nixosConfigurations = { nixosConfigurations = {
"nixos-fix" = nixpkgs.lib.nixosSystem { "nixos-fix" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
pkgs' = config.hardware.asahi.pkgs; pkgs' = config.hardware.asahi.pkgs;
@ -22,14 +27,18 @@ let
fi fi
''; '';
}; };
in { in
{
config = lib.mkIf config.hardware.asahi.enable { config = lib.mkIf config.hardware.asahi.enable {
# install m1n1 with the boot loader # install m1n1 with the boot loader
boot.loader.grub.extraFiles = bootFiles; boot.loader.grub.extraFiles = bootFiles;
boot.loader.systemd-boot.extraFiles = bootFiles; boot.loader.systemd-boot.extraFiles = bootFiles;
# ensure the installer has m1n1 in the image # ensure the installer has m1n1 in the image
system.extraDependencies = lib.mkForce [ bootM1n1 bootUBoot ]; system.extraDependencies = lib.mkForce [
bootM1n1
bootUBoot
];
system.build.m1n1 = bootFiles."m1n1/boot.bin"; system.build.m1n1 = bootFiles."m1n1/boot.bin";
}; };

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
./kernel ./kernel
@ -8,43 +13,52 @@
./sound ./sound
]; ];
config = let config =
let
cfg = config.hardware.asahi; cfg = config.hardware.asahi;
in lib.mkIf cfg.enable { in
lib.mkIf cfg.enable {
nixpkgs.overlays = lib.mkBefore [ cfg.overlay ]; nixpkgs.overlays = lib.mkBefore [ cfg.overlay ];
# patch systemd-boot to boot in Apple Silicon UEFI environment. # patch systemd-boot to boot in Apple Silicon UEFI environment.
# This regression only appeared in systemd 256.7. # This regression only appeared in systemd 256.7.
# see https://github.com/NixOS/nixpkgs/pull/355290 # see https://github.com/NixOS/nixpkgs/pull/355290
# and https://github.com/systemd/systemd/issues/35026 # and https://github.com/systemd/systemd/issues/35026
systemd.package = let systemd.package =
let
systemdBroken = (pkgs.systemd.version == "256.7"); systemdBroken = (pkgs.systemd.version == "256.7");
systemdPatched = pkgs.systemd.overrideAttrs (old: { systemdPatched = pkgs.systemd.overrideAttrs (old: {
patches = let patches =
let
oldPatches = (old.patches or [ ]); oldPatches = (old.patches or [ ]);
# not sure why there are non-paths in there but oh well # not sure why there are non-paths in there but oh well
patchNames = (builtins.map (p: if ((builtins.typeOf p) == "path") then builtins.baseNameOf p else "") oldPatches); patchNames = (
builtins.map (p: if ((builtins.typeOf p) == "path") then builtins.baseNameOf p else "") oldPatches
);
fixName = "0019-Revert-boot-Make-initrd_prepare-semantically-equival.patch"; fixName = "0019-Revert-boot-Make-initrd_prepare-semantically-equival.patch";
alreadyPatched = builtins.elem fixName patchNames; alreadyPatched = builtins.elem fixName patchNames;
in oldPatches ++ lib.optionals (!alreadyPatched) [ in
oldPatches
++ lib.optionals (!alreadyPatched) [
(pkgs.fetchpatch { (pkgs.fetchpatch {
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/125e99477b0ac0a54b7cddc6c5a704821a3074c7/pkgs/os-specific/linux/systemd/${fixName}"; url = "https://raw.githubusercontent.com/NixOS/nixpkgs/125e99477b0ac0a54b7cddc6c5a704821a3074c7/pkgs/os-specific/linux/systemd/${fixName}";
hash = "sha256-UW3DZiaykQUUNcGA5UFxN+/wgNSW3ufxDDCZ7emD16o="; hash = "sha256-UW3DZiaykQUUNcGA5UFxN+/wgNSW3ufxDDCZ7emD16o=";
}) })
]; ];
}); });
in if systemdBroken then systemdPatched else pkgs.systemd; in
if systemdBroken then systemdPatched else pkgs.systemd;
hardware.asahi.pkgs = hardware.asahi.pkgs =
if cfg.pkgsSystem != "aarch64-linux" if cfg.pkgsSystem != "aarch64-linux" then
then
import (pkgs.path) { import (pkgs.path) {
crossSystem.system = "aarch64-linux"; crossSystem.system = "aarch64-linux";
localSystem.system = cfg.pkgsSystem; localSystem.system = cfg.pkgsSystem;
overlays = [ cfg.overlay ]; overlays = [ cfg.overlay ];
} }
else pkgs; else
pkgs;
}; };
options.hardware.asahi = { options.hardware.asahi = {

View file

@ -1,9 +1,15 @@
# the Asahi Linux kernel and options that must go along with it # the Asahi Linux kernel and options that must go along with it
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
config = lib.mkIf config.hardware.asahi.enable { config = lib.mkIf config.hardware.asahi.enable {
boot.kernelPackages = let boot.kernelPackages =
let
pkgs' = config.hardware.asahi.pkgs; pkgs' = config.hardware.asahi.pkgs;
in in
pkgs'.linux-asahi.override { pkgs'.linux-asahi.override {
@ -93,8 +99,11 @@
}; };
imports = [ imports = [
(lib.mkRemovedOptionModule [ "hardware" "asahi" "addEdgeKernelConfig" ] (lib.mkRemovedOptionModule [
"All edge kernel config options are now the default.") "hardware"
"asahi"
"addEdgeKernelConfig"
] "All edge kernel config options are now the default.")
]; ];
options.hardware.asahi.withRust = lib.mkOption { options.hardware.asahi.withRust = lib.mkOption {

View file

@ -1,9 +1,22 @@
{ options, config, pkgs, lib, ... }:
{ {
config = let options,
isMode = mode: (config.hardware.asahi.useExperimentalGPUDriver config,
&& config.hardware.asahi.experimentalGPUInstallMode == mode); pkgs,
in lib.mkIf config.hardware.asahi.enable (lib.mkMerge [ lib,
...
}:
{
config =
let
isMode =
mode:
(
config.hardware.asahi.useExperimentalGPUDriver
&& config.hardware.asahi.experimentalGPUInstallMode == mode
);
in
lib.mkIf config.hardware.asahi.enable (
lib.mkMerge [
{ {
# required for proper DRM setup even without GPU driver # required for proper DRM setup even without GPU driver
services.xserver.config = '' services.xserver.config = ''
@ -21,7 +34,8 @@
# required for in-kernel GPU driver # required for in-kernel GPU driver
hardware.asahi.withRust = true; hardware.asahi.withRust = true;
}) })
]); ]
);
options.hardware.asahi.useExperimentalGPUDriver = lib.mkOption { options.hardware.asahi.useExperimentalGPUDriver = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
@ -35,7 +49,11 @@
# hopefully no longer used, should be deprecated eventually # hopefully no longer used, should be deprecated eventually
options.hardware.asahi.experimentalGPUInstallMode = lib.mkOption { options.hardware.asahi.experimentalGPUInstallMode = lib.mkOption {
type = lib.types.enum [ "driver" "replace" "overlay" ]; type = lib.types.enum [
"driver"
"replace"
"overlay"
];
default = "replace"; default = "replace";
description = '' description = ''
Mode to use to install the experimental GPU driver into the system. Mode to use to install the experimental GPU driver into the system.

View file

@ -1,8 +1,14 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
config = lib.mkIf config.hardware.asahi.enable { config = lib.mkIf config.hardware.asahi.enable {
assertions = lib.mkIf config.hardware.asahi.extractPeripheralFirmware [ assertions = lib.mkIf config.hardware.asahi.extractPeripheralFirmware [
{ assertion = config.hardware.asahi.peripheralFirmwareDirectory != null; {
assertion = config.hardware.asahi.peripheralFirmwareDirectory != null;
message = '' message = ''
Asahi peripheral firmware extraction is enabled but the firmware Asahi peripheral firmware extraction is enabled but the firmware
location appears incorrect. location appears incorrect.
@ -10,15 +16,23 @@
} }
]; ];
hardware.firmware = let hardware.firmware =
let
pkgs' = config.hardware.asahi.pkgs; pkgs' = config.hardware.asahi.pkgs;
in in
lib.mkIf ((config.hardware.asahi.peripheralFirmwareDirectory != null) lib.mkIf
&& config.hardware.asahi.extractPeripheralFirmware) [ (
(config.hardware.asahi.peripheralFirmwareDirectory != null)
&& config.hardware.asahi.extractPeripheralFirmware
)
[
(pkgs.stdenv.mkDerivation { (pkgs.stdenv.mkDerivation {
name = "asahi-peripheral-firmware"; name = "asahi-peripheral-firmware";
nativeBuildInputs = [ pkgs'.asahi-fwextract pkgs.cpio ]; nativeBuildInputs = [
pkgs'.asahi-fwextract
pkgs.cpio
];
buildCommand = '' buildCommand = ''
mkdir extracted mkdir extracted
@ -45,8 +59,7 @@
peripheralFirmwareDirectory = lib.mkOption { peripheralFirmwareDirectory = lib.mkOption {
type = lib.types.nullOr lib.types.path; type = lib.types.nullOr lib.types.path;
default = lib.findFirst (path: builtins.pathExists (path + "/all_firmware.tar.gz")) null default = lib.findFirst (path: builtins.pathExists (path + "/all_firmware.tar.gz")) null [
[
# path when the system is operating normally # path when the system is operating normally
/boot/asahi /boot/asahi
# path when the system is mounted in the installer # path when the system is mounted in the installer

View file

@ -1,4 +1,10 @@
{ config, options, pkgs, lib, ... }: {
config,
options,
pkgs,
lib,
...
}:
{ {
options.hardware.asahi = { options.hardware.asahi = {
@ -12,7 +18,8 @@
}; };
}; };
config = let config =
let
cfg = config.hardware.asahi; cfg = config.hardware.asahi;
asahi-audio = pkgs.asahi-audio; # the asahi-audio we use asahi-audio = pkgs.asahi-audio; # the asahi-audio we use
@ -21,8 +28,13 @@
lsp-plugins-is-safe = (pkgs.lib.versionAtLeast lsp-plugins.version "1.2.14"); lsp-plugins-is-safe = (pkgs.lib.versionAtLeast lsp-plugins.version "1.2.14");
lv2Path = lib.makeSearchPath "lib/lv2" [ lsp-plugins pkgs.bankstown-lv2 ]; lv2Path = lib.makeSearchPath "lib/lv2" [
in lib.mkIf (cfg.setupAsahiSound && cfg.enable) (lib.mkMerge [ lsp-plugins
pkgs.bankstown-lv2
];
in
lib.mkIf (cfg.setupAsahiSound && cfg.enable) (
lib.mkMerge [
{ {
# can't be used by Asahi sound infrastructure # can't be used by Asahi sound infrastructure
services.pulseaudio.enable = false; services.pulseaudio.enable = false;
@ -36,23 +48,32 @@
pulse.enable = true; pulse.enable = true;
configPackages = [ asahi-audio ]; configPackages = [ asahi-audio ];
extraLv2Packages = [ lsp-plugins pkgs.bankstown-lv2 ]; extraLv2Packages = [
lsp-plugins
pkgs.bankstown-lv2
];
wireplumber = { wireplumber = {
enable = true; enable = true;
configPackages = [ asahi-audio ]; configPackages = [ asahi-audio ];
extraLv2Packages = [ lsp-plugins pkgs.bankstown-lv2 ]; extraLv2Packages = [
lsp-plugins
pkgs.bankstown-lv2
];
}; };
}; };
# set up enivronment so that UCM configs are used as well # set up enivronment so that UCM configs are used as well
environment.variables.ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-asahi}/share/alsa/ucm2"; environment.variables.ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-asahi}/share/alsa/ucm2";
systemd.user.services.pipewire.environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2; systemd.user.services.pipewire.environment.ALSA_CONFIG_UCM2 =
systemd.user.services.wireplumber.environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2; config.environment.variables.ALSA_CONFIG_UCM2;
systemd.user.services.wireplumber.environment.ALSA_CONFIG_UCM2 =
config.environment.variables.ALSA_CONFIG_UCM2;
# enable speakersafetyd to protect speakers # enable speakersafetyd to protect speakers
systemd.packages = lib.mkAssert lsp-plugins-is-safe systemd.packages =
lib.mkAssert lsp-plugins-is-safe
"lsp-plugins is unpatched/outdated and speakers cannot be safely enabled" "lsp-plugins is unpatched/outdated and speakers cannot be safely enabled"
[ pkgs.speakersafetyd ]; [ pkgs.speakersafetyd ];
services.udev.packages = [ pkgs.speakersafetyd ]; services.udev.packages = [ pkgs.speakersafetyd ];
@ -66,5 +87,6 @@
} }
]; ];
} }
]); ]
);
} }

View file

@ -1,9 +1,12 @@
{ lib {
, fetchFromGitHub lib,
, alsa-ucm-conf fetchFromGitHub,
alsa-ucm-conf,
}: }:
(alsa-ucm-conf.overrideAttrs (oldAttrs: let (alsa-ucm-conf.overrideAttrs (
oldAttrs:
let
versionAsahi = "5"; versionAsahi = "5";
srcAsahi = fetchFromGitHub { srcAsahi = fetchFromGitHub {
@ -13,10 +16,12 @@
rev = "v${versionAsahi}"; rev = "v${versionAsahi}";
hash = "sha256-daUNz5oUrPfSMO0Tqq/WbtiLHMOtPeQQlI+juGrhTxw="; hash = "sha256-daUNz5oUrPfSMO0Tqq/WbtiLHMOtPeQQlI+juGrhTxw=";
}; };
in { in
{
name = "${oldAttrs.pname}-${oldAttrs.version}-asahi-${versionAsahi}"; name = "${oldAttrs.pname}-${oldAttrs.version}-asahi-${versionAsahi}";
postInstall = oldAttrs.postInstall or "" + '' postInstall = oldAttrs.postInstall or "" + ''
cp -r ${srcAsahi}/ucm2 $out/share/alsa cp -r ${srcAsahi}/ucm2 $out/share/alsa
''; '';
})) }
))

View file

@ -1,6 +1,7 @@
{ stdenv {
, lib stdenv,
, fetchFromGitHub lib,
fetchFromGitHub,
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {

View file

@ -1,9 +1,10 @@
{ lib {
, python3 lib,
, fetchFromGitHub python3,
, gzip fetchFromGitHub,
, gnutar gzip,
, lzfse gnutar,
lzfse,
}: }:
python3.pkgs.buildPythonApplication rec { python3.pkgs.buildPythonApplication rec {

View file

@ -1,11 +1,12 @@
{ lib {
, pkgs lib,
, callPackage pkgs,
, writeShellScriptBin callPackage,
, writeText writeShellScriptBin,
, linuxPackagesFor writeText,
, withRust ? false linuxPackagesFor,
, _kernelPatches ? [ ] withRust ? false,
_kernelPatches ? [ ],
}: }:
let let
@ -13,56 +14,94 @@ let
# parse <OPT> [ymn]|foo style configuration as found in a patch's extraConfig # parse <OPT> [ymn]|foo style configuration as found in a patch's extraConfig
# into a list of k, v tuples # into a list of k, v tuples
parseExtraConfig = config: parseExtraConfig =
config:
let
lines = builtins.filter (s: s != "") (lib.strings.splitString "\n" config);
parseLine =
line:
let let
lines =
builtins.filter (s: s != "") (lib.strings.splitString "\n" config);
parseLine = line: let
t = lib.strings.splitString " " line; t = lib.strings.splitString " " line;
join = l: builtins.foldl' (a: b: "${a} ${b}") join = l: builtins.foldl' (a: b: "${a} ${b}") (builtins.head l) (builtins.tail l);
(builtins.head l) (builtins.tail l);
v = if (builtins.length t) > 2 then join (builtins.tail t) else (i t 1); v = if (builtins.length t) > 2 then join (builtins.tail t) else (i t 1);
in [ "CONFIG_${i t 0}" v ]; in
in map parseLine lines; [
"CONFIG_${i t 0}"
v
];
in
map parseLine lines;
# parse <OPT>=lib.kernel.(yes|module|no)|lib.kernel.freeform "foo" # parse <OPT>=lib.kernel.(yes|module|no)|lib.kernel.freeform "foo"
# style configuration as found in a patch's extraStructuredConfig into # style configuration as found in a patch's extraStructuredConfig into
# a list of k, v tuples # a list of k, v tuples
parseExtraStructuredConfig = config: lib.attrsets.mapAttrsToList parseExtraStructuredConfig =
(k: v: [ "CONFIG_${k}" (v.tristate or v.freeform) ] ) config; config:
lib.attrsets.mapAttrsToList (k: v: [
"CONFIG_${k}"
(v.tristate or v.freeform)
]) config;
parsePatchConfig = { extraConfig ? "", extraStructuredConfig ? {}, ... }: parsePatchConfig =
(parseExtraConfig extraConfig) ++ {
(parseExtraStructuredConfig extraStructuredConfig); extraConfig ? "",
extraStructuredConfig ? { },
...
}:
(parseExtraConfig extraConfig) ++ (parseExtraStructuredConfig extraStructuredConfig);
# parse CONFIG_<OPT>=[ymn]|"foo" style configuration as found in a config file # parse CONFIG_<OPT>=[ymn]|"foo" style configuration as found in a config file
# into a list of k, v tuples # into a list of k, v tuples
parseConfig = config: parseConfig =
config:
let let
parseLine = builtins.match ''(CONFIG_[[:upper:][:digit:]_]+)=(([ymn])|"([^"]*)")''; parseLine = builtins.match ''(CONFIG_[[:upper:][:digit:]_]+)=(([ymn])|"([^"]*)")'';
# get either the [ymn] option or the "foo" option; whichever matched # get either the [ymn] option or the "foo" option; whichever matched
t = l: let v = (i l 2); in [ (i l 0) (if v != null then v else (i l 3)) ]; t =
l:
let
v = (i l 2);
in
[
(i l 0)
(if v != null then v else (i l 3))
];
lines = lib.strings.splitString "\n" config; lines = lib.strings.splitString "\n" config;
in map t (builtins.filter (l: l != null) (map parseLine lines)); in
map t (builtins.filter (l: l != null) (map parseLine lines));
origConfigfile = ./config; origConfigfile = ./config;
linux-asahi-pkg = { stdenv, lib, fetchFromGitHub, fetchpatch, linuxKernel, linux-asahi-pkg =
rustPlatform, rustc, rustfmt, rust-bindgen, ... } @ args: {
stdenv,
lib,
fetchFromGitHub,
fetchpatch,
linuxKernel,
rustPlatform,
rustc,
rustfmt,
rust-bindgen,
...
}@args:
let let
origConfigText = builtins.readFile origConfigfile; origConfigText = builtins.readFile origConfigfile;
# extraConfig from all patches in order # extraConfig from all patches in order
extraConfig = extraConfig = lib.fold (patch: ex: ex ++ (parsePatchConfig patch)) [ ] _kernelPatches;
lib.fold (patch: ex: ex ++ (parsePatchConfig patch)) [] _kernelPatches;
# config file text for above # config file text for above
extraConfigText = let extraConfigText =
text = k: v: if (v == "y") || (v == "m") || (v == "n") let
then "${k}=${v}" else ''${k}="${v}"''; text = k: v: if (v == "y") || (v == "m") || (v == "n") then "${k}=${v}" else ''${k}="${v}"'';
in (map (t: text (i t 0) (i t 1)) extraConfig); in
(map (t: text (i t 0) (i t 1)) extraConfig);
# final config as a text file path # final config as a text file path
configfile = if extraConfig == [] then origConfigfile else configfile =
if extraConfig == [ ] then
origConfigfile
else
writeText "config" '' writeText "config" ''
${origConfigText} ${origConfigText}
@ -70,10 +109,12 @@ let
${lib.strings.concatStringsSep "\n" extraConfigText} ${lib.strings.concatStringsSep "\n" extraConfigText}
''; '';
# final config as an attrset # final config as an attrset
configAttrs = let configAttrs =
let
makePair = t: lib.nameValuePair (i t 0) (i t 1); makePair = t: lib.nameValuePair (i t 0) (i t 1);
configList = (parseConfig origConfigText) ++ extraConfig; configList = (parseConfig origConfigText) ++ extraConfig;
in builtins.listToAttrs (map makePair (lib.lists.reverseList configList)); in
builtins.listToAttrs (map makePair (lib.lists.reverseList configList));
# used to (ostensibly) keep compatibility for those running stable versions of nixos # used to (ostensibly) keep compatibility for those running stable versions of nixos
rustOlder = version: withRust && (lib.versionOlder rustc.version version); rustOlder = version: withRust && (lib.versionOlder rustc.version version);
@ -83,7 +124,8 @@ let
rustAtLeast = version: withRust && (lib.versionAtLeast rustc.version version); rustAtLeast = version: withRust && (lib.versionAtLeast rustc.version version);
bindgenAtLeast = version: withRust && (lib.versionAtLeast rust-bindgen.unwrapped.version version); bindgenAtLeast = version: withRust && (lib.versionAtLeast rust-bindgen.unwrapped.version version);
in in
(linuxKernel.manualConfig rec { (
linuxKernel.manualConfig rec {
inherit stdenv lib; inherit stdenv lib;
version = "6.12.12-asahi"; version = "6.12.12-asahi";
@ -99,24 +141,37 @@ let
}; };
kernelPatches = [ kernelPatches = [
{ name = "coreutils-fix"; {
name = "coreutils-fix";
patch = ./0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch; patch = ./0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch;
} }
] ++ _kernelPatches; ]
++ _kernelPatches;
inherit configfile; inherit configfile;
# hide Rust support from the nixpkgs infra to avoid it re-adding the rust packages. # hide Rust support from the nixpkgs infra to avoid it re-adding the rust packages.
# we can't use it until it's in stable and until we've evaluated the cross-compilation impact. # we can't use it until it's in stable and until we've evaluated the cross-compilation impact.
config = configAttrs // { "CONFIG_RUST" = "n"; }; config = configAttrs // {
} // (args.argsOverride or {})).overrideAttrs (old: if withRust then { "CONFIG_RUST" = "n";
};
}
// (args.argsOverride or { })
).overrideAttrs
(
old:
if withRust then
{
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
rust-bindgen rust-bindgen
rustfmt rustfmt
rustc rustc
]; ];
RUST_LIB_SRC = rustPlatform.rustLibSrc; RUST_LIB_SRC = rustPlatform.rustLibSrc;
} else {}); }
else
{ }
);
linux-asahi = (callPackage linux-asahi-pkg { }); linux-asahi = (callPackage linux-asahi-pkg { });
in lib.recurseIntoAttrs (linuxPackagesFor linux-asahi) in
lib.recurseIntoAttrs (linuxPackagesFor linux-asahi)

View file

@ -1,29 +1,36 @@
{ stdenv {
, buildPackages stdenv,
, lib buildPackages,
, fetchFromGitHub lib,
, python3 fetchFromGitHub,
, dtc python3,
, imagemagick dtc,
, isRelease ? false imagemagick,
, withTools ? true isRelease ? false,
, withChainloading ? false withTools ? true,
, rust-bin ? null withChainloading ? false,
, customLogo ? null rust-bin ? null,
customLogo ? null,
}: }:
assert withChainloading -> rust-bin != null; assert withChainloading -> rust-bin != null;
let let
pyenv = python3.withPackages (p: with p; [ pyenv = python3.withPackages (
p: with p; [
construct construct
pyserial pyserial
]); ]
);
rustenv = rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal.override { rustenv = rust-bin.selectLatestNightlyWith (
toolchain:
toolchain.minimal.override {
targets = [ "aarch64-unknown-none-softfloat" ]; targets = [ "aarch64-unknown-none-softfloat" ];
}); }
in stdenv.mkDerivation rec { );
in
stdenv.mkDerivation rec {
pname = "m1n1"; pname = "m1n1";
version = "1.4.21"; version = "1.4.21";
@ -36,14 +43,17 @@ in stdenv.mkDerivation rec {
fetchSubmodules = true; fetchSubmodules = true;
}; };
makeFlags = [ "ARCH=${stdenv.cc.targetPrefix}" ] makeFlags = [
"ARCH=${stdenv.cc.targetPrefix}"
]
++ lib.optional isRelease "RELEASE=1" ++ lib.optional isRelease "RELEASE=1"
++ lib.optional withChainloading "CHAINLOADING=1"; ++ lib.optional withChainloading "CHAINLOADING=1";
nativeBuildInputs = [ nativeBuildInputs = [
dtc dtc
buildPackages.gcc buildPackages.gcc
] ++ lib.optional withChainloading rustenv ]
++ lib.optional withChainloading rustenv
++ lib.optional (customLogo != null) imagemagick; ++ lib.optional (customLogo != null) imagemagick;
postPatch = '' postPatch = ''
@ -72,7 +82,8 @@ in stdenv.mkDerivation rec {
mkdir -p $out/build mkdir -p $out/build
cp build/m1n1.bin $out/build cp build/m1n1.bin $out/build
'' + (lib.optionalString withTools '' ''
+ (lib.optionalString withTools ''
mkdir -p $out/{bin,script,toolchain-bin} mkdir -p $out/{bin,script,toolchain-bin}
cp -r proxyclient $out/script cp -r proxyclient $out/script
cp -r tools $out/script cp -r tools $out/script
@ -95,7 +106,8 @@ EOF
ln -s $BINUTILS/bin/${stdenv.cc.targetPrefix}objcopy $out/toolchain-bin/ ln -s $BINUTILS/bin/${stdenv.cc.targetPrefix}objcopy $out/toolchain-bin/
ln -s $BINUTILS/bin/${stdenv.cc.targetPrefix}objdump $out/toolchain-bin/ ln -s $BINUTILS/bin/${stdenv.cc.targetPrefix}objdump $out/toolchain-bin/
ln -s $GCC/bin/${stdenv.cc.targetPrefix}nm $out/toolchain-bin/ ln -s $GCC/bin/${stdenv.cc.targetPrefix}nm $out/toolchain-bin/
'') + '' '')
+ ''
runHook postInstall runHook postInstall
''; '';
} }

View file

@ -1,12 +1,21 @@
{ lib {
, fetchFromGitLab lib,
, mesa fetchFromGitLab,
mesa,
}: }:
(mesa.override { (mesa.override {
galliumDrivers = [ "softpipe" "llvmpipe" "asahi" ]; galliumDrivers = [
vulkanDrivers = [ "swrast" "asahi" ]; "softpipe"
}).overrideAttrs (oldAttrs: { "llvmpipe"
"asahi"
];
vulkanDrivers = [
"swrast"
"asahi"
];
}).overrideAttrs
(oldAttrs: {
version = "25.0.0-asahi"; version = "25.0.0-asahi";
src = fetchFromGitLab { src = fetchFromGitLab {
# tracking: https://pagure.io/fedora-asahi/mesa/commits/asahi # tracking: https://pagure.io/fedora-asahi/mesa/commits/asahi
@ -17,7 +26,8 @@
hash = "sha256-Ny4M/tkraVLhUK5y6Wt7md1QBtqQqPDUv+aY4MpNA6Y="; hash = "sha256-Ny4M/tkraVLhUK5y6Wt7md1QBtqQqPDUv+aY4MpNA6Y=";
}; };
mesonFlags = let mesonFlags =
let
badFlags = [ badFlags = [
"-Dinstall-mesa-clc" "-Dinstall-mesa-clc"
"-Dopencl-spirv" "-Dopencl-spirv"
@ -25,7 +35,9 @@
]; ];
isBadFlagList = f: builtins.map (b: lib.hasPrefix b f) badFlags; isBadFlagList = f: builtins.map (b: lib.hasPrefix b f) badFlags;
isGoodFlag = f: !(builtins.foldl' (x: y: x || y) false (isBadFlagList f)); isGoodFlag = f: !(builtins.foldl' (x: y: x || y) false (isBadFlagList f));
in (builtins.filter isGoodFlag oldAttrs.mesonFlags) ++ [ in
(builtins.filter isGoodFlag oldAttrs.mesonFlags)
++ [
# we do not build any graphics drivers these features can be enabled for # we do not build any graphics drivers these features can be enabled for
"-Dgallium-va=disabled" "-Dgallium-va=disabled"
"-Dgallium-vdpau=disabled" "-Dgallium-vdpau=disabled"

View file

@ -1,7 +1,8 @@
{ lib {
, fetchFromGitHub lib,
, buildUBoot fetchFromGitHub,
, m1n1 buildUBoot,
m1n1,
}: }:
(buildUBoot rec { (buildUBoot rec {
@ -28,7 +29,8 @@
CONFIG_VIDEO_FONT_16X32=y CONFIG_VIDEO_FONT_16X32=y
CONFIG_CMD_BOOTMENU=y CONFIG_CMD_BOOTMENU=y
''; '';
}).overrideAttrs (o: { }).overrideAttrs
(o: {
# nixos's downstream patches are not applicable # nixos's downstream patches are not applicable
patches = [ patches = [
]; ];

View file

@ -2,7 +2,12 @@
# your system. Help is available in the configuration.nix(5) man page, on # your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). # https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
{ {
imports = [ imports = [
@ -62,7 +67,6 @@
}; };
}; };
# Configure keymap in X11 # Configure keymap in X11
# services.xserver.xkb.layout = "us"; # services.xserver.xkb.layout = "us";
# services.xserver.xkb.options = "eurosign:e,caps:escape"; # services.xserver.xkb.options = "eurosign:e,caps:escape";
@ -106,4 +110,3 @@
system.stateVersion = "25.05"; # Did you read the comment? system.stateVersion = "25.05"; # Did you read the comment?
} }

View file

@ -1,27 +1,39 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[ (modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "usb_storage" "sdhci_pci" ]; boot.initrd.availableKernelModules = [
"usb_storage"
"sdhci_pci"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ]; boot.kernelModules = [ ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-uuid/6b7a615f-ed15-4dbc-9d6b-aac66c679bac"; device = "/dev/disk/by-uuid/6b7a615f-ed15-4dbc-9d6b-aac66c679bac";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{ device = "/dev/disk/by-uuid/4D74-1AFF"; device = "/dev/disk/by-uuid/4D74-1AFF";
fsType = "vfat"; fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ]; options = [
"fmask=0022"
"dmask=0022"
];
}; };
swapDevices = [ ]; swapDevices = [ ];

View file

@ -1,4 +1,10 @@
{ inputs, config, pkgs, lib, ... }: {
inputs,
config,
pkgs,
lib,
...
}:
{ {
imports = [ imports = [

View file

@ -1,7 +1,13 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = [ imports = [

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
documentation = { documentation = {

View file

@ -1,16 +1,10 @@
# **************************************************************************** # {
# # inputs,
# ::: :::::::: # config,
# configuration.nix :+: :+: :+: # pkgs,
# +:+ +:+ +:+ # lib,
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ # ...
# +#+#+#+#+#+ +#+ # }:
# Created: 2025/10/02 00:54:38 by rparodi #+# #+# #
# Updated: 2025/10/02 11:44:15 by rparodi ### ########.fr #
# #
# **************************************************************************** #
{ inputs, config, pkgs, lib, ... }:
{ {
imports = [ imports = [
@ -57,14 +51,6 @@
}; };
}; };
programs = {
steam = {
enable = true;
gamescopeSession.enable = true;
};
gamemode.enable = true;
};
users = { users = {
defaultUserShell = pkgs.zsh; defaultUserShell = pkgs.zsh;
users = { users = {
@ -85,7 +71,6 @@
}; };
}; };
# Bootloader. # Bootloader.
boot.loader = { boot.loader = {
systemd-boot.enable = true; systemd-boot.enable = true;
@ -94,14 +79,6 @@
services = { services = {
seatd.enable = true; seatd.enable = true;
displayManager = {
defaultSession = "steam";
gdm.enable = true;
autoLogin = {
enable = true;
user = "raphael";
};
};
xserver = { xserver = {
enable = true; enable = true;
videoDrivers = [ videoDrivers = [
@ -130,8 +107,6 @@
enable = true; enable = true;
}; };
}; };
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
system.stateVersion = "24.05"; system.stateVersion = "24.05";
} }

View file

@ -1,7 +1,13 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = [ imports = [

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
lutris = import ./lutris.nix { lutris = import ./lutris.nix {
@ -12,6 +17,18 @@ in
]; ];
options.games = { options.games = {
steam = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable steam installation";
};
bp = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable the autostart of steam in big picture";
};
};
lutris = lib.mkOption { lutris = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.games.lutris; cfg = config.games.lutris;

49
modules/games/steam.nix Normal file
View file

@ -0,0 +1,49 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.games.steam;
in
{
config = lib.mkIf cfg.enable {
programs.steam = {
enable = true;
gamescopeSession.enable = true;
extraCompatPackages = with pkgs; [
proton-ge-bin
];
};
programs.gamemode.enable = true;
systemd.user.services."steam-bp" = lib.mkIf cfg.bp {
description = "Steam Big Picture auto start";
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExecStart = "${pkgs.steam}/bin/steam -tenfoot -fulldesktopres";
Restart = "on-failure";
Environment = [
"SDL_VIDEO_X11_DGAMOUSE=0"
"STEAM_USE_OGL=1"
"GAMEMODERUNEXEC=1"
];
};
};
services = {
desktopManager.plasma6.enable = lib.mkIf cfg.bp true;
displayManager = lib.mkIf cfg.bp {
defaultSession = "plasmax11";
sddm.enable = true;
autoLogin = {
enable = true;
user = "raphael";
};
};
};
};
}

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.bot_discord.ada; cfg = config.service.bot_discord.ada;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.bot_discord.bde; cfg = config.service.bot_discord.bde;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.bot_discord.tut; cfg = config.service.bot_discord.tut;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.bot_discord.marty; cfg = config.service.bot_discord.marty;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.bot_discord.master; cfg = config.service.bot_discord.master;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.bot_discord.music; cfg = config.service.bot_discord.music;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.bot_discord.tempvoc; cfg = config.service.bot_discord.tempvoc;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.bot_discord.ticket; cfg = config.service.bot_discord.ticket;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
master_bot = import ./bot_discord/master.nix { master_bot = import ./bot_discord/master.nix {

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
irc = import ./forty_two/irc.nix { irc = import ./forty_two/irc.nix {

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.forty_two.irc; cfg = config.service.forty_two.irc;

View file

@ -1,8 +1,19 @@
{ inputs, config, pkgs, lib, ... }: {
inputs,
config,
pkgs,
lib,
...
}:
let let
enium-pv = import ./games/minecraft.nix { enium-pv = import ./games/minecraft.nix {
inherit inputs config pkgs lib; inherit
inputs
config
pkgs
lib
;
}; };
cfg = config.service; cfg = config.service;
in in

View file

@ -1,4 +1,10 @@
{ inputs, config, pkgs, lib, ... }: {
inputs,
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.games.enium-pv; cfg = config.service.games.enium-pv;

View file

@ -1,23 +1,59 @@
{ inputs, config, pkgs, lib, ... }: {
inputs,
config,
pkgs,
lib,
...
}:
let let
htop = import ./self_host/htop.nix { htop = import ./self_host/htop.nix {
inherit inputs config pkgs lib; inherit
inputs
config
pkgs
lib
;
}; };
mail = import ./self_host/mail.nix { mail = import ./self_host/mail.nix {
inherit inputs config pkgs lib; inherit
inputs
config
pkgs
lib
;
}; };
monitor = import ./self_host/monitor.nix { monitor = import ./self_host/monitor.nix {
inherit inputs config pkgs lib; inherit
inputs
config
pkgs
lib
;
}; };
teamspeak = import ./self_host/teamspeak.nix { teamspeak = import ./self_host/teamspeak.nix {
inherit inputs config pkgs lib; inherit
inputs
config
pkgs
lib
;
}; };
ollama = import ./self_host/ollama.nix { ollama = import ./self_host/ollama.nix {
inherit inputs config pkgs lib; inherit
inputs
config
pkgs
lib
;
}; };
nextcloud = import ./self_host/nextcloud.nix { nextcloud = import ./self_host/nextcloud.nix {
inherit inputs config pkgs lib; inherit
inputs
config
pkgs
lib
;
}; };
cfg = config.service.selfhost; cfg = config.service.selfhost;
in in

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.selfhost.monitor; cfg = config.service.selfhost.monitor;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.selfhost.mail; cfg = config.service.selfhost.mail;

View file

@ -1,8 +1,16 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.selfhost.monitor; cfg = config.service.selfhost.monitor;
monitored = [ "nginx" "grafana" ]; monitored = [
"nginx"
"grafana"
];
email = "raphael@enium.eu"; email = "raphael@enium.eu";
in in
{ {
@ -58,29 +66,35 @@ in
{ {
job_name = "systemd_exporter"; job_name = "systemd_exporter";
metrics_path = "/metrics"; metrics_path = "/metrics";
static_configs = [{ static_configs = [
{
targets = [ targets = [
"127.0.0.1:9558" "127.0.0.1:9558"
]; ];
}]; }
];
} }
{ {
job_name = "node_exporter"; job_name = "node_exporter";
static_configs = [{ static_configs = [
{
targets = [ targets = [
"127.0.0.1:9100" "127.0.0.1:9100"
]; ];
}]; }
];
} }
{ {
job_name = "process_exporter"; job_name = "process_exporter";
metrics_path = "/metrics"; metrics_path = "/metrics";
scheme = "http"; scheme = "http";
static_configs = [{ static_configs = [
{
targets = [ targets = [
"127.0.0.1:9256" "127.0.0.1:9256"
]; ];
}]; }
];
} }
{ {
job_name = "blackbox_http_probe"; job_name = "blackbox_http_probe";
@ -90,7 +104,8 @@ in
"http_2xx" "http_2xx"
]; ];
}; };
static_configs = [{ static_configs = [
{
targets = [ targets = [
"https://raphael.parodi.pro" "https://raphael.parodi.pro"
"https://nextcloud.enium.eu" "https://nextcloud.enium.eu"
@ -99,15 +114,19 @@ in
"https://ollama.enium.eu" "https://ollama.enium.eu"
"http://relance-pas-stp.me:4242" "http://relance-pas-stp.me:4242"
]; ];
}]; }
];
relabel_configs = [ relabel_configs = [
{ source_labels = [ "__address__" ]; {
source_labels = [ "__address__" ];
target_label = "__param_target"; target_label = "__param_target";
} }
{ source_labels = [ "__param_target" ]; {
source_labels = [ "__param_target" ];
target_label = "instance"; target_label = "instance";
} }
{ target_label = "__address__"; {
target_label = "__address__";
replacement = "127.0.0.1:9115"; replacement = "127.0.0.1:9115";
} }
]; ];

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.selfhost.nextcloud; cfg = config.service.selfhost.nextcloud;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.selfhost.ollama; cfg = config.service.selfhost.ollama;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.selfhost.monitor; cfg = config.service.selfhost.monitor;

View file

@ -1,8 +1,19 @@
{ inputs, config, pkgs, lib, ... }: {
inputs,
config,
pkgs,
lib,
...
}:
let let
portefolio = import ./web/portefolio.nix { portefolio = import ./web/portefolio.nix {
inherit inputs config pkgs lib; inherit
inputs
config
pkgs
lib
;
}; };
cfg = config.service.web; cfg = config.service.web;
in in

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.service.web.portefolio; cfg = config.service.web.portefolio;