-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #582 from isabelroses/master
refactor(flake): improve usage
- Loading branch information
Showing
4 changed files
with
86 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
}; | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
}; | ||
|
||
outputs = {self, nixpkgs}@inputs : | ||
let | ||
system = "x86_64-linux"; # replace this as needed | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
auto-cpufreq = pkgs.python3Packages.callPackage ./nix/default.nix {}; | ||
in { | ||
packages.${system}.default = auto-cpufreq; | ||
outputs = {nixpkgs, ...} @ inputs: let | ||
forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "i686-linux" "aarch64-linux"]; | ||
pkgsForEach = nixpkgs.legacyPackages; | ||
in { | ||
packages = forAllSystems (system: { | ||
default = pkgsForEach.${system}.python3Packages.callPackage ./nix/default.nix {}; | ||
}); | ||
|
||
devShells.${system}.default = pkgs.mkShell { | ||
inputsFrom = [ auto-cpufreq ]; | ||
packages = [ pkgs.python310Packages.pip ]; | ||
}; | ||
devShells = forAllSystems (system: { | ||
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {}; | ||
}); | ||
|
||
nixosModules.default = import ./nix/module.nix inputs; | ||
}; | ||
nixosModules.default = import ./nix/module.nix inputs; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,45 @@ | ||
inputs: { config, lib, pkgs, options, ... }: | ||
|
||
inputs: { | ||
config, | ||
lib, | ||
pkgs, | ||
options, | ||
... | ||
}: | ||
with lib; let | ||
cfg = config.programs.auto-cpufreq; | ||
inherit (pkgs.stdenv.hostPlatform) system; | ||
defaultPackage = inputs.self.packages.${system}.default; | ||
cfgFilename = "auto-cpufreq.conf"; | ||
cfgFile = format.generate cfgFilename cfg.settings; | ||
|
||
cfg = config.programs.auto-cpufreq; | ||
system = "x86_64-linux"; | ||
defaultPackage = inputs.self.packages.${system}.default; | ||
cfgFilename = "auto-cpufreq.conf"; | ||
cfgFile = format.generate cfgFilename cfg.settings; | ||
|
||
format = pkgs.formats.ini {}; | ||
|
||
format = pkgs.formats.ini {}; | ||
in { | ||
options.programs.auto-cpufreq = { | ||
enable = mkEnableOption "Automatic CPU speed & power optimizer for Linux"; | ||
|
||
options.programs.auto-cpufreq = { | ||
enable = mkEnableOption "Automatic CPU speed & power optimizer for Linux"; | ||
settings = mkOption { | ||
description = mdDoc '' | ||
Configuration for `auto-cpufreq`. | ||
settings = mkOption { | ||
description = lib.mdDoc '' | ||
Configuration for `auto-cpufreq`. | ||
See its [example configuration file] for supported settings. | ||
[example configuration file]: https://github.com/AdnanHodzic/auto-cpufreq/blob/master/auto-cpufreq.conf-example | ||
''; | ||
|
||
See its [example configuration file] for supported settings. | ||
[example configuration file]: https://github.com/AdnanHodzic/auto-cpufreq/blob/master/auto-cpufreq.conf-example | ||
''; | ||
|
||
default = {}; | ||
type = types.submodule { freeformType = format.type; }; | ||
}; | ||
default = {}; | ||
type = types.submodule {freeformType = format.type;}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
environment.systemPackages = [ defaultPackage ]; | ||
|
||
services.auto-cpufreq.enable = true; | ||
systemd.services.auto-cpufreq = { | ||
overrideStrategy = "asDropin"; | ||
serviceConfig.ExecStart = lib.mkForce [ | ||
"" | ||
"${defaultPackage}/bin/auto-cpufreq --daemon --config ${cfgFile}" | ||
]; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
environment.systemPackages = [defaultPackage]; | ||
|
||
services.auto-cpufreq.enable = true; | ||
systemd.services.auto-cpufreq = { | ||
overrideStrategy = "asDropin"; | ||
serviceConfig.ExecStart = mkForce [ | ||
"" | ||
"${defaultPackage}/bin/auto-cpufreq --daemon --config ${cfgFile}" | ||
]; | ||
}; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
python310Packages, | ||
python3Packages, | ||
... | ||
}: let | ||
mainPkg = python3Packages.callPackage ./default.nix {}; | ||
in | ||
mainPkg.overrideAttrs (oa: { | ||
nativeBuildInputs = | ||
[ | ||
python310Packages.pip | ||
] | ||
++ (oa.nativeBuildInputs or []); | ||
}) |