Compare commits

...

3 Commits

Author SHA1 Message Date
c84fae413b
core: fix overlay to merge package sets 2020-10-17 12:55:56 +11:00
6cd420d7af
services: port amdgpu services from private config 2020-10-17 12:55:56 +11:00
326f4b9fec
docs: update README 2020-10-17 12:55:53 +11:00
7 changed files with 203 additions and 37 deletions

View File

@ -1,37 +1,46 @@
# nur-packages-template
**A template for [NUR](https://github.com/nix-community/NUR) repositories**
## Setup
1. Click on [Use this template](https://github.com/nix-community/nur-packages-template/generate) to start a repo based on this template. (Do _not_ fork it.)
2. Add your packages to the [pkgs](./pkgs) directory and to
[default.nix](./default.nix)
* Remember to mark the broken packages as `broken = true;` in the `meta`
attribute, or travis (and consequently caching) will fail!
* Library functions, modules and overlays go in the respective directories
3. Choose your CI: Depending on your preference you can use github actions (recommended) or [Travis ci](https://travis-ci.com).
- Github actions: Change your NUR repo name and optionally add a cachix name in [.github/workflows/build.yml](./.github/workflows/build.yml) and change the cron timer
to a random value as described in the file
- Travis ci: Change your NUR repo name and optionally your cachix repo name in
[.travis.yml](./.travis.yml). Than enable travis in your repo. You can add a cron job in the repository settings on travis to keep your cachix cache fresh
5. Change your travis and cachix names on the README template section and delete
the rest
6. [Add yourself to NUR](https://github.com/nix-community/NUR#how-to-add-your-own-repository)
## README template
# nur-packages # nur-packages
**My personal [NUR](https://github.com/nix-community/NUR) repository** **My personal [NUR](https://github.com/nix-community/NUR) repository**
<!-- Remove this if you don't use github actions --> [![Build Status](https://travis-ci.com/xeals/nur-packages.svg?branch=master)](https://travis-ci.com/xeals/nur-packages)
![Build and populate cache](https://github.com/nix-community/<YOUR-GITHUB-USER>/workflows/Build%20and%20populate%20cache/badge.svg) [![Cachix Cache](https://img.shields.io/badge/cachix-xeals-blue.svg)](https://xeals.cachix.org)
<!-- ## Noteworthy packages
Uncomment this if you use travis:
[![Build Status](https://travis-ci.com/<YOUR_TRAVIS_USERNAME>/nur-packages.svg?branch=master)](https://travis-ci.com/<YOUR_TRAVIS_USERNAME>/nur-packages) ### Jetbrains with plugins
-->
[![Cachix Cache](https://img.shields.io/badge/cachix-<YOUR_CACHIX_CACHE_NAME>-blue.svg)](https://<YOUR_CACHIX_CACHE_NAME>.cachix.org)
A fan of the Emacs/Vim/VSCode plugin builder? Now enjoy it with your favourite Jetbrains IDE!
The system is mostly proof-of-concept and there are a couple of issues with it at the moment, but it works for what is available in the repo.
#### Using
```nix
{ pkgs ? import <nixpkgs> {} }:
let
xeals = import (builtins.fetchTarball "https://git.xeal.me/xeals/nur-packages/archive/master.tar.gz") {
inherit pkgs;
};
in
# e.g., for IntelliJ IDEA
xeals.jetbrains.ideaCommunityWithPlugins (jpkgs: [
jpkgs.ideavim
jpgs.checkstyle-idea
])
```
#### Issues
- [ ] The plugin derivation overrides the base instead of extending it; this is really only an issue for the open-source IDEs, and only once they're actually built from source (instead of repackaging the JARs)
- [ ] Plugins must be manually added to the repo; long-term, I'd really want some way to scrape them, or at least have a script to add and update
### spotify-ripper
`spotify-ripper` is pretty flexible in the formats it supports, so the derivation allows you to customize which support packages to build with.
The default package comes with nothing (which is not entirely useful -- this will probably change at some point). See [the builder](./pkgs/tools/misc/spotify-ripper/default.nix) for options.
## General issues
- [ ] `spotify-ripper` does not build on stable NixOS channels before 20.09 when built with m4a or mp4 support, as `fdk-aac-encoder` is not available
- [ ] Due to weirdness in fixed output hashes, anything using `buildGoModule` and `buildRustPackage` will fail on unstable channels of Nixpkgs, and must be overridden if you want to use these packages on unstable channels

View File

@ -1,6 +1,7 @@
{ {
# Add your NixOS modules here amdgpu-common = ./services/hardware/amdgpu-common.nix;
# amdgpu-fan = ./services/hardware/amdgpu-fan.nix;
# my-module = ./my-module; amdgpu-pwm = ./services/hardware/amdgpu-pwm.nix;
radeon-profile-daemon = ./services/hardware/radeon-profile-daemon.nix;
} }

View File

@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
{
options.services.amdgpu = {
cards = mkOption {
type = types.listOf types.str;
default = [ "card0" ];
example = literalExample ''[ "card0" ]'';
description = ''
A list of cards to enable fan configuration for. The identifiers for
each device can be found in /sys/class/drm/ as card0, card1, etc.
'';
};
};
}

View File

@ -0,0 +1,71 @@
{ config, lib, pkgs, ... }:
with lib;
let
acfg = config.services.amdgpu;
cfg = config.services.amdgpu.fan;
in
{
options.services.amdgpu.fan = {
enable = mkEnableOption "amdgpu-fan";
speedMatrix = mkOption {
type = with types; listOf (listOf int);
# Translated from upstream default config. Since it tries to write the
# config if it's not found, we want some kind of default.
default = [
[ 0 0 ]
[ 30 33 ]
[ 45 50 ]
[ 60 66 ]
[ 65 69 ]
[ 70 75 ]
[ 75 89 ]
[ 80 100 ]
];
example = literalExample ''
[
[ 0 0 ]
[ 40 30 ]
[ 60 50 ]
[ 80 100 ]
]
'';
description = ''
A list of temperature-fan speed pairs. The temperature is specified in
degrees celcius, and speed is specified in %.
'';
};
};
config = mkIf cfg.enable {
assertions = singleton {
assertion = all (speeds: length speeds == 2) cfg.speedMatrix;
message = "services.amdgpu-fan.speedMatrix must be a list of paired lists";
};
environment.etc."amdgpu-fan.yml".text = builtins.toJSON {
speed_matrix = cfg.speedMatrix;
cards = acfg.cards;
};
powerManagement.resumeCommands = "${pkgs.systemd}/bin/systemctl try-restart amdgpu-fan";
# Translated from the upstream service file.
systemd.services = {
amdgpu-fan = {
description = "amdgpu fan controller";
wantedBy = [ "default.target" ];
after = [ "enable-manual-amdgpu-fan.service" ];
serviceConfig = {
ExecStart = "${pkgs.amdgpu-fan}/bin/amdgpu-fan";
Restart = "always";
};
};
};
};
}

View File

@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
with lib;
let
acfg = config.services.amdgpu;
cfg = config.services.amdgpu.pwm;
in
{
options.services.amdgpu.pwm = {
enable = mkEnableOption "amdgpu-pwm";
};
config = mkIf cfg.enable {
systemd.services.amdgpu-pwm = {
description = "enable manual configuration of AMDGPU fans";
wantedBy = [ "default.target" ];
script =
let
enablePwm = card: "echo 1 > /sys/class/drm/${card}/device/hwmon/hwmon1/pwm1_enable";
in
lib.concatStringsSep "\n" (map enablePwm acfg.cards);
serviceConfig.Type = "oneshot";
};
};
}

View File

@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.radeon-profile-daemon;
in
{
options.services.radeon-profile-daemon = {
enable = mkEnableOption "radeon-profile-daemon";
};
config = mkIf cfg.enable {
systemd.services = {
radeon-profile-daemon = {
description = "radeon-profile daemon";
wantedBy = [ "multi-user.target" ];
after = [ "enable-manual-amdgpu-fan.service" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.radeon-profile-daemon}/bin/radeon-profile-daemon";
};
};
};
};
}

View File

@ -10,9 +10,19 @@ let
nameValuePair = n: v: { name = n; value = v; }; nameValuePair = n: v: { name = n; value = v; };
nurAttrs = import ./default.nix { pkgs = super; }; nurAttrs = import ./default.nix { pkgs = super; };
overlay =
builtins.listToAttrs
(map (n: nameValuePair n nurAttrs.${n})
(builtins.filter (n: !isReserved n)
(builtins.attrNames nurAttrs)));
in in
builtins.listToAttrs # Shadow existing package sets if they already exist rather than replacing.
(map (n: nameValuePair n nurAttrs.${n}) overlay //
(builtins.filter (n: !isReserved n) {
(builtins.attrNames nurAttrs))) goModules = (super.goModules or { }) // (overlay.goModules or { });
jetbrains = (super.jetbrains or { }) // (overlay.jetbrains or { });
python2Packages = (super.python2Packages or { }) // (overlay.python2Packages or { });
python3Packages = (super.python3Packages or { }) // (overlay.python3Packages or { });
}