Compare commits

..

27 commits

Author SHA1 Message Date
Your Name
dd18c6753a better fix for recent nix versions 2022-06-16 13:11:41 +02:00
busti
f868637417 automatically restart spotifyd and pulseaudio daily 2022-01-22 17:22:02 +01:00
busti
c5349029ab fix spotifyd service config and firewall setup 2022-01-18 21:30:58 +01:00
d1ebaa7a86
update inputs 2021-12-12 01:23:52 +01:00
956e105dfb
add readme 2021-11-12 03:29:51 +01:00
c698432f2f
Revert temporary fix for "store path ... is not allowed to have references"
The issue is now solved upstream: https://github.com/NixOS/nix/issues/5410
2021-11-12 03:29:46 +01:00
dbfb1dfc17 Merge pull request 'Fix spotifyd' (#2) from lagertonne/c3h-nixfiles:fix_spotifyd into main
Reviewed-on: #2
2021-11-08 16:33:27 +00:00
lagertonne
aaaff04b8c Add correct ports to fix spotify-connect detection 2021-11-04 20:21:19 +01:00
lagertonne
3678349769 Fix pulseaudio so that spotifyd works okay 2021-11-04 20:18:34 +01:00
457f4ac1af
move desktop-related programs to shared-services/desktop 2021-10-30 11:37:44 +02:00
busti
8d654cb086 install vlc, sox and ffmpeg 2021-10-25 13:56:01 +02:00
busti
70bfccd5f6 install pavucontrol and dosbox 2021-10-25 13:56:01 +02:00
7a0544f69a
tmpfsOnTmpfs true on bemmer 2021-10-25 00:12:51 +02:00
51a691efbf
fix deprecation warning
use settings attribute
2021-10-24 23:38:49 +02:00
349bc436a4
fix alias 2021-10-24 23:21:31 +02:00
106b0cec8a
Merge https://git.neulandlabor.de/busti/c3h-nixfiles into HEAD 2021-10-24 23:19:59 +02:00
3e8b76b643
simplify bemmer config some more 2021-10-24 22:56:43 +02:00
8ac7010414
move around users definition 2021-10-24 22:43:11 +02:00
3c80614ee4
update bemmer config 2021-10-24 20:55:28 +02:00
c7dce3b8c0
add nfs client 2021-10-24 20:55:12 +02:00
035b623b42
update deploy script 2021-10-24 20:54:29 +02:00
busti
90f258df05 add alias for apt 2021-10-24 20:28:19 +02:00
08cb02d7d9
add new host bemmer 2021-10-23 00:26:56 +02:00
c576495bb2
update deploy script to support aarch64 2021-10-23 00:26:39 +02:00
e2efc79686
add nixos-hardware repo 2021-10-23 00:26:04 +02:00
dda25e506c
switch to nixos-unstable 2021-10-23 00:25:51 +02:00
ab24240216
move stuff to shared-services 2021-10-23 00:25:25 +02:00
14 changed files with 176 additions and 64 deletions

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# Leitstelle config management
To deploy, run `./deploy.sh switch <host>`, where the host is nuc or bemmer.

View file

@ -1,7 +1,7 @@
{ lib, pkgs, ... }: { lib, pkgs, ... }:
{ {
boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; boot.kernelPackages = lib.mkOverride 2000 pkgs.linuxPackages_latest;
boot.kernelParams = [ "quiet" ]; boot.kernelParams = [ "quiet" ];
services.openssh.enable = true; services.openssh.enable = true;
@ -38,6 +38,7 @@
vim vim
wget wget
jq jq
lsof
]; ];
programs.bash.shellAliases = { programs.bash.shellAliases = {
@ -49,5 +50,13 @@
ll = "exa -l"; ll = "exa -l";
la = "exa -la"; la = "exa -la";
tree = "exa -T"; tree = "exa -T";
apt = "echo 'please use nix-env -iA nixos.<packagename> instead to install packages.'";
};
users.mutableUsers = false;
users.users.c3h = {
isNormalUser = true;
password = "c3h";
extraGroups = [ "wheel" ];
}; };
} }

View file

@ -6,21 +6,30 @@ cd "$(dirname "$0")"
if ! command -v nix-build &> /dev/null if ! command -v nix-build &> /dev/null
then then
echo "Nix installation could not be found. Please follow the instructions linked below." echo "Nix installation could not be found. Please follow the instructions linked below."
echo "https://nixos.org/manual/nix/unstable/installation/installing-binary.html#multi-user-installation" echo "https://nixos.org/manual/nix/unstable/installation/installing-binary.html"
exit exit
fi fi
mode="${1:-switch}" mode="${1:-switch}"
host="${2:-nuc}" host="${2:-nuc}"
target="${3:-$host.c3h}" target="${3:-c3h@$host.c3h}"
if ! [ -d "hosts/$host" ]
then
echo "Host $host does not exist. Choose from:"
ls hosts
exit
fi
echo "deploying $host to $target" echo "deploying $host to $target"
sleep 1 sleep 1
sources=$(nix-build nix/sources-dir.nix --no-out-link)
set -x set -x
system_drv=$(nix-instantiate "<nixpkgs/nixos>" -I $sources -I "nixos-config=$PWD/hosts/$host/configuration.nix" | head -n1) system_drv=$(
nix-instantiate "<nixpkgs/nixos>" -A config.system.build.toplevel \
-I "$(nix-build nix/sources-dir.nix --no-out-link)" \
-I "nixos-config=$PWD/hosts/$host/configuration.nix"
)
nix-copy-closure --to $target $system_drv nix-copy-closure --to $target $system_drv
system=$(ssh $target "nix-store --realise $system_drv") system=$(ssh $target "nix-store --realise $system_drv")
ssh $target "sudo nix-env -p /nix/var/nix/profiles/system -i $system && sudo /nix/var/nix/profiles/system/bin/switch-to-configuration $mode" ssh $target "sudo nix-env -p /nix/var/nix/profiles/system -i $system && sudo /nix/var/nix/profiles/system/bin/switch-to-configuration $mode"

View file

@ -8,7 +8,7 @@
# services # services
../../shared-services/pulseaudio.nix ../../shared-services/pulseaudio.nix
#../../shared-services/nfs-server.nix ../../shared-services/nfs-client.nix
../../shared-services/mpd.nix ../../shared-services/mpd.nix
../../shared-services/ympd.nix ../../shared-services/ympd.nix
../../shared-services/spotifyd.nix ../../shared-services/spotifyd.nix
@ -16,28 +16,21 @@
../../shared-services/vnc.nix ../../shared-services/vnc.nix
../../shared-services/webserver.nix ../../shared-services/webserver.nix
]; ];
users.users.c3h = {
isNormalUser = true; # We import sd-image-aarch64.nix so we can build a config.system.build.sdImage
password = "c3h"; # But it imports some modules we don't want, so disable them
extraGroups = [ "wheel" ]; disabledModules = [
packages = with pkgs; [ chromium firefox mpv youtube-dl ]; "profiles/base.nix"
}; "profiles/all-hardware.nix"
];
networking.hostName = "bemmer"; networking.hostName = "bemmer";
networking.domain = "c3h"; networking.domain = "c3h";
networking.useDHCP = true; networking.useDHCP = true;
nixpkgs.system = "aarch64-linux"; nixpkgs.system = "aarch64-linux";
boot.initrd.availableKernelModules = lib.mkForce [ "vc4" "i2c_bcm2835" ]; hardware.raspberry-pi."4".fkms-3d.enable = true;
boot.supportedFilesystems = lib.mkForce [ "ext4" "vfat" ]; boot.tmpOnTmpfs = true; # building stuff on sd-card is slow
boot.kernelPackages = pkgs.linuxPackages_rpi4;
documentation.enable = false;
hardware.raspberry-pi."4" = {
fkms-3d.enable = true;
#audio.enable = true;
};
system.stateVersion = "21.05"; system.stateVersion = "21.05";
} }

View file

@ -8,7 +8,7 @@
# services # services
../../shared-services/pulseaudio.nix ../../shared-services/pulseaudio.nix
../../shared-services/nfs-server.nix ../../shared-services/nfs-client.nix
../../shared-services/mpd.nix ../../shared-services/mpd.nix
../../shared-services/ympd.nix ../../shared-services/ympd.nix
../../shared-services/spotifyd.nix ../../shared-services/spotifyd.nix

View file

@ -23,7 +23,7 @@
fsType = "vfat"; fsType = "vfat";
}; };
fileSystems."/mnt" = fileSystems."/mnt/hdd" =
{ device = "/dev/disk/by-uuid/ff18a6f9-ee3b-452c-8671-38b74508a74c"; { device = "/dev/disk/by-uuid/ff18a6f9-ee3b-452c-8671-38b74508a74c";
fsType = "btrfs"; fsType = "btrfs";
}; };

68
modules/spotifyd.nix Normal file
View file

@ -0,0 +1,68 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.spotifyd;
toml = pkgs.formats.toml {};
warnConfig =
if cfg.config != ""
then lib.trace "Using the stringly typed .config attribute is discouraged. Use the TOML typed .settings attribute instead."
else id;
spotifydConf =
if cfg.settings != {}
then toml.generate "spotify.conf" cfg.settings
else warnConfig (pkgs.writeText "spotifyd.conf" cfg.config);
in
{
options = {
services.spotifyd = {
enable = mkEnableOption "spotifyd, a Spotify playing daemon";
config = mkOption {
default = "";
type = types.lines;
description = ''
(Deprecated) Configuration for Spotifyd. For syntax and directives, see
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
'';
};
settings = mkOption {
default = {};
type = toml.type;
example = { global.bitrate = 320; };
description = ''
Configuration for Spotifyd. For syntax and directives, see
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.config == "" || cfg.settings == {};
message = "At most one of the .config attribute and the .settings attribute may be set";
}
];
systemd.services.spotifyd = {
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" "sound.target" ];
description = "spotifyd, a Spotify playing daemon";
environment.SHELL = "/bin/sh";
serviceConfig = {
ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --config-path ${spotifydConf}";
Restart = "always";
RestartSec = 12;
DynamicUser = true;
CacheDirectory = "spotifyd";
SupplementaryGroups = ["audio"];
};
};
};
meta.maintainers = [ maintainers.anderslundstedt ];
}

View file

@ -9,6 +9,6 @@ in
lib.concatStringsSep "\n" ([ lib.concatStringsSep "\n" ([
"mkdir $out" "mkdir $out"
] ]
++ lib.mapAttrsToList (name: source: "ln -s ${source.outPath} $out/${name}") sources ++ lib.mapAttrsToList (name: source: "cp -r --reflink=auto ${source.outPath} $out/${name}") sources
) )
) )

View file

@ -5,10 +5,10 @@
"homepage": "https://github.com/nmattia/niv", "homepage": "https://github.com/nmattia/niv",
"owner": "nmattia", "owner": "nmattia",
"repo": "niv", "repo": "niv",
"rev": "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070", "rev": "5830a4dd348d77e39a0f3c4c762ff2663b602d4c",
"sha256": "1pq9nh1d8nn3xvbdny8fafzw87mj7gsmp6pxkdl65w2g18rmcmzx", "sha256": "1d3lsrqvci4qz2hwjrcnd8h5vfkg8aypq3sjd4g3izbc8frwz5sm",
"type": "tarball", "type": "tarball",
"url": "https://github.com/nmattia/niv/archive/e0ca65c81a2d7a4d82a189f1e23a48d59ad42070.tar.gz", "url": "https://github.com/nmattia/niv/archive/5830a4dd348d77e39a0f3c4c762ff2663b602d4c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"nixos-hardware": { "nixos-hardware": {
@ -17,10 +17,10 @@
"homepage": "", "homepage": "",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixos-hardware", "repo": "nixos-hardware",
"rev": "3aabf78bfcae62f5f99474f2ebbbe418f1c6e54f", "rev": "2a7063461c3751d83869a2a0a8ebc59e34bec5b2",
"sha256": "10g240brgjz7qi20adwajxwqrqb5zxc79ii1mc20fasgqlf2a8sx", "sha256": "173ms858wni43l2p7vqjarm2bnjdhpii0zgn46750nyfff1f2184",
"type": "tarball", "type": "tarball",
"url": "https://github.com/NixOS/nixos-hardware/archive/3aabf78bfcae62f5f99474f2ebbbe418f1c6e54f.tar.gz", "url": "https://github.com/NixOS/nixos-hardware/archive/2a7063461c3751d83869a2a0a8ebc59e34bec5b2.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"nixpkgs": { "nixpkgs": {
@ -29,10 +29,10 @@
"homepage": "", "homepage": "",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "34ad3ffe08adfca17fcb4e4a47bb5f3b113687be", "rev": "581d2d6c9cd5c289002203581d8aa0861963a933",
"sha256": "02li241rz5668nfyp88zfjilxf0mr9yansa93fbl38hjwkhf3ix6", "sha256": "1qpmqj075pppa6ihmkacf491lhq7rpxlcm8cm6h18raardsr3irr",
"type": "tarball", "type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/34ad3ffe08adfca17fcb4e4a47bb5f3b113687be.tar.gz", "url": "https://github.com/NixOS/nixpkgs/archive/581d2d6c9cd5c289002203581d8aa0861963a933.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
} }
} }

View file

@ -1,13 +1,17 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
users.mutableUsers = false; users.users.c3h.packages = with pkgs; [
users.users.c3h = { chromium
isNormalUser = true; firefox
password = "c3h"; mpv
extraGroups = [ "wheel" ]; youtube-dl
packages = with pkgs; [ chromium firefox mpv youtube-dl ]; pavucontrol
}; dosbox
vlc
ffmpeg-full
sox
];
services.xserver = { services.xserver = {
enable = true; enable = true;

View file

@ -0,0 +1,15 @@
{ ... }:
{
boot.supportedFilesystems = [ "nfs" ];
fileSystems."/mnt/Music" = {
device = "10.23.42.126:/music";
fsType = "nfs";
options = [
"nfsvers=4.1"
"noauto"
"x-systemd.automount"
"x-systemd.idle-timeout=600"
];
};
}

View file

@ -1,17 +0,0 @@
{ ... }:
{
services.nfs.server = {
enable = true;
exports = ''
/mnt 10.23.42.0/24(rw,fsid=0,insecure,no_subtree_check)
'';
statdPort = 4000;
lockdPort = 4001;
mountdPort = 4002;
};
networking.firewall.interfaces.enp3s0.allowedTCPPorts = [ 2049 4000 4001 4002 111 ];
networking.firewall.interfaces.enp3s0.allowedUDPPorts = [ 2049 4000 4001 4002 111 ];
}

View file

@ -5,8 +5,12 @@
sound.enable = true; sound.enable = true;
hardware.pulseaudio.enable = true; hardware.pulseaudio.enable = true;
hardware.pulseaudio.systemWide = true; hardware.pulseaudio.systemWide = true;
hardware.pulseaudio.package = pkgs.pulseaudio; hardware.pulseaudio.package = pkgs.pulseaudioFull;
hardware.pulseaudio.tcp.enable = true; hardware.pulseaudio.tcp.enable = true;
hardware.pulseaudio.tcp.anonymousClients.allowedIpRanges = [ "127.0.0.0/8" "::/64" "10.23.42.0/24" ]; hardware.pulseaudio.tcp.anonymousClients.allowedIpRanges = [ "127.0.0.0/8" "::/64" "10.23.42.0/24" ];
environment.variables.PULSE_SERVER = "127.0.0.1"; environment.variables.PULSE_SERVER = "127.0.0.1";
hardware.pulseaudio.extraConfig = ''
unload-module module-native-protocol-unix
load-module module-native-protocol-unix auth-anonymous=1
'';
} }

View file

@ -1,12 +1,36 @@
{ ... }: { config, pkgs, ... }:
{ {
disabledModules = [ "services/audio/spotifyd.nix" ];
imports = [ ../modules/spotifyd.nix ];
services.spotifyd = { services.spotifyd = {
enable = true; enable = true;
config = '' settings.global = {
zeroconf_port = 18572 bitrate = 320;
zeroconf_port = 18572;
};
};
networking.firewall.allowedTCPPorts = [ 4070 config.services.spotifyd.settings.global.zeroconf_port ];
networking.firewall.allowedUDPPorts = [ 5353 ];
systemd.services.restart-spotifyd = {
serviceConfig.Type = "oneshot";
script = ''
${pkgs.systemd}/bin/systemctl restart spotifyd.service
${pkgs.systemd}/bin/systemctl restart pulseaudio.service
''; '';
}; };
networking.firewall.allowedTCPPorts = [ 18572 ]; systemd.timers.restart-spotifyd = {
wantedBy = [ "timers.target" ];
partOf = [ "restart-spotifyd.service" ];
timerConfig = {
OnCalendar = "*-*-* 07:00:00";
Persistent = "True";
Unit = "restart-spotifyd.service";
};
};
} }