From 6cb18a664904afae03501ee613797f502030ee37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 5 May 2024 07:13:06 +0200 Subject: [PATCH] purism/librem/5r4: make it usuable without an overlay In larger installations nixpkgs.overlays adds significant overhead because it's harder to share nixpkgs between different NixOS machines i.e. using nixpkgs.pkgs --- purism/librem/5r4/audio.nix | 2 +- purism/librem/5r4/default.nix | 25 ++++++++++------------- purism/librem/5r4/{kernel => }/kernel.nix | 0 purism/librem/5r4/kernel/default.nix | 3 --- purism/librem/5r4/lockdown-fix.nix | 2 +- 5 files changed, 13 insertions(+), 19 deletions(-) rename purism/librem/5r4/{kernel => }/kernel.nix (100%) delete mode 100644 purism/librem/5r4/kernel/default.nix diff --git a/purism/librem/5r4/audio.nix b/purism/librem/5r4/audio.nix index e44e2f3..80c1c87 100644 --- a/purism/librem/5r4/audio.nix +++ b/purism/librem/5r4/audio.nix @@ -9,7 +9,7 @@ enable = true; # this is required to correctly configure the modem as PA source/sink extraConfig = '' - .include ${pkgs.librem5-base}/etc/pulse/librem5.pa + .include ${config.hardware.librem5.package}/etc/pulse/librem5.pa ''; }; diff --git a/purism/librem/5r4/default.nix b/purism/librem/5r4/default.nix index 83c7fb3..76854a6 100644 --- a/purism/librem/5r4/default.nix +++ b/purism/librem/5r4/default.nix @@ -1,8 +1,15 @@ { config, pkgs, lib, ... }: -let cfg = config.hardware.librem5; +let + cfg = config.hardware.librem5; + linuxPackages_librem5 = pkgs.linuxPackagesFor (pkgs.callPackage ./kernel.nix { }); + ubootLibrem5 = pkgs.callPackage ./u-boot { }; in { options = { hardware.librem5 = { + package = lib.mkOption { + type = lib.types.package; + default = pkgs.callPackage ./librem5-base { }; + }; wifiCard = lib.mkOption { type = lib.types.enum [ "redpine" "sparklan" "none" ]; description = lib.mdDoc '' @@ -42,15 +49,6 @@ in { lockdownFix = lib.mkDefault true; }; - nixpkgs.overlays = [ - (import ./kernel) - (final: prev: { - ubootLibrem5 = final.callPackage ./u-boot { }; - - librem5-base = final.callPackage ./librem5-base { }; - }) - ]; - boot = { kernelParams = [ "rootwait" ]; @@ -59,12 +57,11 @@ in { grub.enable = false; }; - kernelPackages = lib.mkDefault pkgs.linuxPackages_librem5; + kernelPackages = lib.mkDefault linuxPackages_librem5; }; - services.udev.packages = lib.mkIf cfg.installUdevPackages [ pkgs.librem5-base ]; - - environment.systemPackages = with pkgs; [ ubootLibrem5 ]; + services.udev.packages = lib.mkIf cfg.installUdevPackages [ config.hardware.librem5.package ]; + environment.systemPackages = [ ubootLibrem5 ]; }; } diff --git a/purism/librem/5r4/kernel/kernel.nix b/purism/librem/5r4/kernel.nix similarity index 100% rename from purism/librem/5r4/kernel/kernel.nix rename to purism/librem/5r4/kernel.nix diff --git a/purism/librem/5r4/kernel/default.nix b/purism/librem/5r4/kernel/default.nix deleted file mode 100644 index 7b1b085..0000000 --- a/purism/librem/5r4/kernel/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -final: prev: { - linuxPackages_librem5 = final.linuxPackagesFor (final.callPackage ./kernel.nix { }); -} diff --git a/purism/librem/5r4/lockdown-fix.nix b/purism/librem/5r4/lockdown-fix.nix index 00e5041..121ded3 100644 --- a/purism/librem/5r4/lockdown-fix.nix +++ b/purism/librem/5r4/lockdown-fix.nix @@ -11,7 +11,7 @@ lib.mkIf config.hardware.librem5.lockdownFix { systemd.services.librem5-lockdown-support = { description = "Set up drivers for the orientation and proximity sensors on Librem 5"; serviceConfig.Type = "oneshot"; - serviceConfig.ExecStart = "${pkgs.librem5-base}/bin/lockdown-support.sh"; + serviceConfig.ExecStart = "${config.hardware.librem5.package}/bin/lockdown-support.sh"; wantedBy = [ "default.target" ]; path = [ pkgs.kmod ]; };