Skip to content

Commit

Permalink
Merge branch 'system76-firmware-and-nixos' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shlevy committed Sep 23, 2020
2 parents 17cec95 + 4b1850b commit dc6ff60
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 4 deletions.
56 changes: 56 additions & 0 deletions nixos/modules/hardware/system-76.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{ config, lib, pkgs, ... }:

let
inherit (lib) mkOption mkEnableOption types mkIf mkMerge optional versionOlder;
cfg = config.hardware.system76;

kpkgs = config.boot.kernelPackages;
modules = [ "system76" "system76-io" ] ++ (optional (versionOlder kpkgs.kernel.version "5.5") "system76-acpi");
modulePackages = map (m: kpkgs.${m}) modules;
moduleConfig = mkIf cfg.kernel-modules.enable {
boot.extraModulePackages = modulePackages;

boot.kernelModules = modules;

services.udev.packages = modulePackages;
};

firmware-pkg = pkgs.system76-firmware;
firmwareConfig = mkIf cfg.firmware-daemon.enable {
services.dbus.packages = [ firmware-pkg ];

systemd.services.system76-firmware-daemon = {
description = "The System76 Firmware Daemon";

serviceConfig = {
ExecStart = "${firmware-pkg}/bin/system76-firmware-daemon";

Restart = "on-failure";
};

wantedBy = [ "multi-user.target" ];
};
};
in {
options = {
hardware.system76 = {
enableAll = mkEnableOption "all recommended configuration for system76 systems";

firmware-daemon.enable = mkOption {
default = cfg.enableAll;
example = true;
description = "Whether to enable the system76 firmware daemon";
type = types.bool;
};

kernel-modules.enable = mkOption {
default = cfg.enableAll;
example = true;
description = "Whether to make the system76 out-of-tree kernel modules available";
type = types.bool;
};
};
};

config = mkMerge [ moduleConfig firmwareConfig ];
}
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
./hardware/printers.nix
./hardware/raid/hpsa.nix
./hardware/steam-hardware.nix
./hardware/system-76.nix
./hardware/tuxedo-keyboard.nix
./hardware/usb-wwan.nix
./hardware/onlykey.nix
Expand Down
8 changes: 4 additions & 4 deletions pkgs/build-support/rust/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
, target ? null
, cargoVendorDir ? null
, checkType ? buildType

, depsExtraArgs ? {}
# Needed to `pushd`/`popd` into a subdir of a tarball if this subdir
# contains a Cargo.toml, but isn't part of a workspace (which is e.g. the
# case for `rustfmt`/etc from the `rust-sources).
Expand All @@ -43,11 +43,11 @@ assert buildType == "release" || buildType == "debug";
let

cargoDeps = if cargoVendorDir == null
then fetchCargoTarball {
then fetchCargoTarball ({
inherit name src srcs sourceRoot unpackPhase cargoUpdateHook;
patches = cargoPatches;
sha256 = cargoSha256;
}
} // depsExtraArgs)
else null;

# If we have a cargoSha256 fixed-output derivation, validate it at build time
Expand Down Expand Up @@ -83,7 +83,7 @@ let

in

stdenv.mkDerivation (args // {
stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // {
inherit cargoDeps;

patchRegistryDeps = ./patch-registry-deps;
Expand Down
38 changes: 38 additions & 0 deletions pkgs/os-specific/linux/firmware/firmware-manager/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{ rustPlatform, lib, fetchFromGitHub, lzma, pkgconfig, openssl, dbus, glib, udev, cairo, pango, atk, gdk-pixbuf, gtk3, wrapGAppsHook }:
rustPlatform.buildRustPackage rec {
pname = "firmware-manager";
version = "0.1.1";

src = fetchFromGitHub {
owner = "pop-os";
repo = pname;
rev = version;
sha256 = "0x9604jsflqxvbkfp139mzjicpyx8v21139jj8bp88c14ngvmdlw";
};

nativeBuildInputs = [ pkgconfig wrapGAppsHook ];

buildInputs = [ lzma openssl dbus glib udev cairo pango atk gdk-pixbuf gtk3 ];

depsExtraArgs.postPatch = "make prefix='$(out)' toml-gen";

postPatch = ''
sed -i 's|etc|$(prefix)/etc|' Makefile
'';

buildPhase = "make prefix='$(out)'";

installPhase = "make prefix='$(out)' install";

cargoSha256 = "0byc0pqa1w2qnfrx3psrzdq1c8qjslbmzxg872b9v6fr5d4c9cvg";

doCheck = false;

meta = {
description = "Graphical frontend for firmware management";
homepage = "https://github.com/pop-os/firmware-manager";
license = lib.licenses.gpl3;
maintainers = [ lib.maintainers.shlevy ];
platforms = lib.platforms.linux;
};
}
39 changes: 39 additions & 0 deletions pkgs/os-specific/linux/firmware/system76-firmware/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ rustPlatform, lib, fetchFromGitHub, lzma, pkgconfig, openssl, dbus, efibootmgr, makeWrapper }:
rustPlatform.buildRustPackage rec {
pname = "system76-firmware";
# Check Makefile when updating, make sure postInstall matches make install
version = "1.0.17";

src = fetchFromGitHub {
owner = "pop-os";
repo = pname;
rev = version;
sha256 = "0cnrskfk3sam90lfpgsraqs4bx9yz8rxhwfs8rxdri04lakxgghg";
};

nativeBuildInputs = [ pkgconfig makeWrapper ];

buildInputs = [ lzma openssl dbus ];

cargoBuildFlags = [ "--workspace" ];

cargoSha256 = "06jrmxy68glcmbn9px29wc0s8pqdn26iy4jn3c246dapv1zvbb4s";

# Purposefully don't install systemd unit file, that's for NixOS
postInstall = ''
install -D -m -0644 data/system76-firmware-daemon.conf $out/etc/dbus-1/system.d/system76-firmware-daemon.conf
for bin in $out/bin/system76-firmware-*
do
wrapProgram $bin --prefix PATH : "${efibootmgr}/bin"
done
'';

meta = {
description = "Tools for managing firmware updates for system76 devices.";
homepage = "https://github.com/pop-os/system76-firmware";
license = lib.licenses.gpl3;
maintainers = [ lib.maintainers.shlevy ];
platforms = lib.platforms.linux;
};
}
2 changes: 2 additions & 0 deletions pkgs/os-specific/linux/system76-acpi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ stdenv.mkDerivation {

installPhase = ''
install -D system76_acpi.ko $out/lib/modules/${kernel.modDirVersion}/misc/system76_acpi.ko
mkdir -p $out/lib/udev/hwdb.d
mv lib/udev/hwdb.d/* $out/lib/udev/hwdb.d
'';

meta = with stdenv.lib; {
Expand Down
2 changes: 2 additions & 0 deletions pkgs/os-specific/linux/system76/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ stdenv.mkDerivation {

installPhase = ''
install -D system76.ko $out/lib/modules/${kernel.modDirVersion}/misc/system76.ko
mkdir -p $out/lib/udev/hwdb.d
mv lib/udev/hwdb.d/* $out/lib/udev/hwdb.d
'';

meta = with stdenv.lib; {
Expand Down
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17474,6 +17474,8 @@ in

fwupd = callPackage ../os-specific/linux/firmware/fwupd { };

firmware-manager = callPackage ../os-specific/linux/firmware/firmware-manager { };

fwts = callPackage ../os-specific/linux/fwts { };

gobi_loader = callPackage ../os-specific/linux/gobi_loader { };
Expand Down Expand Up @@ -18282,6 +18284,8 @@ in

nvme-cli = callPackage ../os-specific/linux/nvme-cli { };

system76-firmware = callPackage ../os-specific/linux/firmware/system76-firmware { };

open-vm-tools = callPackage ../applications/virtualization/open-vm-tools { };
open-vm-tools-headless = open-vm-tools.override { withX = false; };

Expand Down

0 comments on commit dc6ff60

Please sign in to comment.