de-flake: part 1

This commit is contained in:
Grimmauld 2024-05-06 23:22:32 +02:00
parent fb1ab5ec9c
commit 6960ecd6c3
Signed by: Grimmauld
GPG key ID: C2946668769F91FB
7 changed files with 132 additions and 190 deletions

View file

@ -27,6 +27,7 @@ in
imports = [
./spotify.nix
./midi.nix
./pipewireLowLatency.nix
];
options.grimmShared.sound.enable = lib.mkEnableOption "whether to enable sound";

View file

@ -0,0 +1,119 @@
# source: https://github.com/fufexan/nix-gaming/raw/master/modules/pipewireLowLatency.nix
{
config,
pkgs,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) int;
inherit (lib.generators) toLua;
cfg = config.services.pipewire.lowLatency;
qr = "${toString cfg.quantum}/${toString cfg.rate}";
in {
# low-latency PipeWire configuration
# extends the nixpkgs module
meta.maintainers = with lib.maintainers; [fufexan];
options = {
services.pipewire.lowLatency = {
enable = mkEnableOption ''
low latency for PipeWire. This will also set `services.pipewire.enable` and
`services.pipewire.wireplumber.enable` to true.
'';
quantum = mkOption {
description = "Minimum quantum to set";
type = int;
default = 64;
example = 32;
};
rate = mkOption {
description = "Rate to set";
type = int;
default = 48000;
example = 96000;
};
};
};
config = mkIf cfg.enable {
services.pipewire = {
# make sure PipeWire is enabled if the module is imported
# and low latency is enabledd
enable = true;
# write extra config
extraConfig.pipewire = {
"99-lowlatency" = {
context = {
properties.default.clock.min-quantum = cfg.quantum;
modules = [
{
name = "libpipewire-module-rtkit";
flags = ["ifexists" "nofail"];
args = {
nice.level = -15;
rt = {
prio = 88;
time.soft = 200000;
time.hard = 200000;
};
};
}
{
name = "libpipewire-module-protocol-pulse";
args = {
server.address = ["unix:native"];
pulse.min = {
req = qr;
quantum = qr;
frag = qr;
};
};
}
];
stream.properties = {
node.latency = qr;
resample.quality = 1;
};
};
};
};
# ensure WirePlumber is enabled explicitly (defaults to true while PW is enabled)
# and write extra config to ship low latency rules for alsa
wireplumber = {
enable = true;
configPackages = let
# generate "matches" section of the rules
matches = toLua {
multiline = false; # looks better while inline
indent = false;
} [[["node.name" "matches" "alsa_output.*"]]]; # nested lists are to produce `{{{ }}}` in the output
# generate "apply_properties" section of the rules
apply_properties = toLua {} {
"audio.format" = "S32LE";
"audio.rate" = cfg.rate * 2;
"api.alsa.period-size" = 2;
};
in [
(pkgs.writeTextDir "share/lowlatency.lua.d/99-alsa-lowlatency.lua" ''
-- Generated by nix-gaming
alsa_monitor.rules = {
{
matches = ${matches};
apply_properties = ${apply_properties};
}
}
'')
];
};
};
};
}

View file

@ -65,7 +65,11 @@ in
core.autocrlf = "input";
commit.gpgsign = true;
pull.rebase = true;
alias.pfusch = "push --force-with-lease";
alias = {
pfusch = "push --force-with-lease --force-if-includes";
fuck = "reset HEAD~1";
fixup = "commit --fixup";
};
};
};

View file

@ -11,9 +11,9 @@ in
nixpkgs-review
nixpkgs-fmt
nixfmt-rfc-style
nixd
# inputs.nix-locate.packages."${system}".default
inputs.hammering.packages."${system}".default
nixpkgs-hammering
nix-output-monitor
nix-search-cli
];

View file

@ -248,56 +248,6 @@
"url": "https://flakehub.com/f/edolstra/flake-compat/%2A.tar.gz"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_3": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1714641030,
"narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-schemas": {
"locked": {
"lastModified": 1693491534,
@ -332,28 +282,6 @@
"url": "https://flakehub.com/f/numtide/flake-utils/0.1.%2A.tar.gz"
}
},
"hammering": {
"inputs": {
"flake-compat": "flake-compat_2",
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1711325025,
"narHash": "sha256-kr3zMr7aWt4W/+Jcol5Ctiq0KjXSxViPhGtyqvX9dqE=",
"owner": "jtojnar",
"repo": "nixpkgs-hammering",
"rev": "6851ecea8c6da45870b7c06d6495cba3fb2d7c7c",
"type": "github"
},
"original": {
"owner": "jtojnar",
"repo": "nixpkgs-hammering",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -496,27 +424,6 @@
"type": "github"
}
},
"nix-gaming": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1714872073,
"narHash": "sha256-Gybo6MqJ2tva9vMaSxOgie8uVObiP0LxD2FMokiR0X4=",
"owner": "fufexan",
"repo": "nix-gaming",
"rev": "b85b9c3afa1bfee0150580eb76c52e572a85a6a9",
"type": "github"
},
"original": {
"owner": "fufexan",
"repo": "nix-gaming",
"type": "github"
}
},
"nix-github-actions": {
"inputs": {
"nixpkgs": [
@ -540,27 +447,6 @@
"type": "github"
}
},
"nix-locate": {
"inputs": {
"flake-compat": "flake-compat_3",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1713342678,
"narHash": "sha256-h+YsV4sODXtS2ZCi+SzdEGQivBXrChByciF+67ATWME=",
"owner": "nix-community",
"repo": "nix-index",
"rev": "3cc5fc9acfe4c739c60ea519188f7a795c3484ef",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-index",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1714906307,
@ -577,18 +463,6 @@
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1714640452,
"narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1711460390,
@ -642,9 +516,6 @@
"inputs": {
"agenix": "agenix",
"chaotic": "chaotic",
"hammering": "hammering",
"nix-gaming": "nix-gaming",
"nix-locate": "nix-locate",
"nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable_2"
}
@ -723,39 +594,6 @@
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"yafas": {
"inputs": {
"flake-schemas": [

View file

@ -6,9 +6,6 @@
url = "github:NixOS/nixpkgs/nixos-unstable";
# url = "git+file:///home/grimmauld/coding/nixpkgs";
};
nixpkgs-stable = {
url = "github:NixOS/nixpkgs/nixos-23.11";
};
chaotic = {
url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
inputs.nixpkgs.follows = "nixpkgs";
@ -17,36 +14,20 @@
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-locate = {
url = "github:nix-community/nix-index";
inputs.nixpkgs.follows = "nixpkgs";
};
hammering = {
url = "github:jtojnar/nixpkgs-hammering";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ { self, nix-gaming, agenix, hammering, nixpkgs, nixpkgs-stable, nix-locate, chaotic, ... }:
outputs = inputs @ { self, agenix, nixpkgs, chaotic, ... }:
let
patches = [
{
# tlpui
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/305278.patch";
hash = "sha256-8RvPI8Id+Ttgv07IMBTAxkSc+K00WhiWgdgrCcULd7o=";
hash = "sha256-vmzj7gF8jwHdqxN+dQiJ4MRxKpHvBTzbrUvFgt1DK8I=";
}
];
customNixosSystem = system: definitions:
let
stable = import nixpkgs-stable {
inherit system;
config.allowUnfree = true;
};
unpatched = nixpkgs.legacyPackages.${system};
patched = unpatched.applyPatches {
name = "nixpkgs-patched";
@ -57,7 +38,7 @@
in
nixosSystem ({
inherit system;
specialArgs = { inherit inputs system stable; };
specialArgs = { inherit inputs system; };
} // definitions);
in
{
@ -66,7 +47,6 @@
modules = [
agenix.nixosModules.default
chaotic.nixosModules.default
nix-gaming.nixosModules.pipewireLowLatency
./overlays
./common
./specific/grimm-nixos-laptop/configuration.nix

View file

@ -1,4 +1,4 @@
{ lib, config, pkgs, stable, ... }: {
{ lib, config, pkgs, ... }: {
users.users.grimmauld = {
isNormalUser = true;
# shell = pkgs.xonsh;
@ -27,7 +27,7 @@
];
packages = with pkgs; [
stable.jetbrains.clion
jetbrains.clion
jetbrains.idea-community
webcord