diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix index 383b40d..ccb9c5c 100644 --- a/nix/configuration/configuration.nix +++ b/nix/configuration/configuration.nix @@ -9,6 +9,7 @@ imports = [ ./roles/2ship2harkinian ./roles/alacritty + ./roles/amd_s2idle ./roles/ansible ./roles/ares ./roles/bluetooth diff --git a/nix/configuration/hosts/odo/default.nix b/nix/configuration/hosts/odo/default.nix index 18c22ff..2aad4d6 100644 --- a/nix/configuration/hosts/odo/default.nix +++ b/nix/configuration/hosts/odo/default.nix @@ -59,6 +59,7 @@ # services.fstrim.enable = lib.mkDefault true; me.alacritty.enable = true; + me.amd_s2idle.enable = true; me.ansible.enable = true; me.ares.enable = true; me.bluetooth.enable = true; diff --git a/nix/configuration/hosts/quark/default.nix b/nix/configuration/hosts/quark/default.nix index 3ab36c7..bb5e86a 100644 --- a/nix/configuration/hosts/quark/default.nix +++ b/nix/configuration/hosts/quark/default.nix @@ -54,6 +54,7 @@ me.rpcs3.config.Core."Use LLVM CPU" = "znver4"; me.alacritty.enable = true; + me.amd_s2idle.enable = true; me.ansible.enable = true; me.ares.enable = true; me.bluetooth.enable = true; diff --git a/nix/configuration/roles/amd_s2idle/default.nix b/nix/configuration/roles/amd_s2idle/default.nix new file mode 100644 index 0000000..ace417a --- /dev/null +++ b/nix/configuration/roles/amd_s2idle/default.nix @@ -0,0 +1,59 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + options.me = { + amd_s2idle.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install amd_s2idle."; + }; + }; + + config = lib.mkIf config.me.amd_s2idle.enable ( + lib.mkMerge [ + { + environment.systemPackages = with pkgs; [ + amd_s2idle + ]; + nixpkgs.overlays = [ + ( + final: prev: + let + innerPackage = (final.callPackage ./package.nix { }); + in + { + amd_s2idle = innerPackage; + # amd_s2idle = final.buildEnv { + # name = innerPackage.name; + # paths = [ + # innerPackage + # ]; + # nativeBuildInputs = [ final.makeWrapper ]; + # postBuild = '' + # wrapProgram $out/bin/amd_s2idle --prefix PATH : ${ + # lib.makeBinPath [ + # (final.python3.withPackages (python-pkgs: [ + # python-pkgs.distro # For https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py + # python-pkgs.pyudev # For https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py + # python-pkgs.systemd # For https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py + # python-pkgs.packaging # For https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py + # ])) + # ] + # } + # ''; + # }; + } + ) + ]; + } + ] + ); +} diff --git a/nix/configuration/roles/amd_s2idle/package.nix b/nix/configuration/roles/amd_s2idle/package.nix new file mode 100644 index 0000000..c417687 --- /dev/null +++ b/nix/configuration/roles/amd_s2idle/package.nix @@ -0,0 +1,54 @@ +# unpackPhase +# patchPhase +# configurePhase +# buildPhase +# checkPhase +# installPhase +# fixupPhase +# installCheckPhase +# distPhase +{ + stdenv, + pkgs, + sqlite, + makeWrapper, + lib, + python3, + ... +}: +stdenv.mkDerivation { + name = "amd_s2idle"; + src = pkgs.fetchgit { + url = "https://gitlab.freedesktop.org/drm/amd.git"; + rev = "0f486d26c05044cebe2c61143bfd56899eef716f"; + sha256 = "sha256-Q1QTaxuvtVKEizO7OHudhcZzxrgcYRgGJOvLDQPMGZ0="; + }; + buildInputs = [ ]; + nativeBuildInputs = [ makeWrapper ]; + phases = [ + "installPhase" + # "fixupPhase" + ]; + installPhase = '' + runHook preInstall + mkdir -p $out/bin + cp $src/scripts/amd_s2idle.py $out/bin/amd_s2idle + runHook postInstall + ''; + postInstall = '' + sed -i 's@#!/usr/bin/python3@#!/usr/bin/env python3@g' $out/bin/amd_s2idle + wrapProgram $out/bin/amd_s2idle --prefix PATH : ${ + lib.makeBinPath [ + (python3.withPackages (python-pkgs: [ + python-pkgs.distro # For https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py + python-pkgs.pyudev # For https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py + python-pkgs.systemd # For https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py + python-pkgs.packaging # For https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py + ])) + ] + } + ''; + # fixupPhase = '' + # patchShebangs $out/bin/.amd_s2idle-wrapped + # ''; +}