Compare commits
	
		
			22 Commits
		
	
	
		
			spotifyd
			...
			misc-gitea
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						c51ecabf52
	
				 | 
					
					
						|||
| d64d8edd68 | |||
| 4de7bd09bd | |||
| 0f5c48902b | |||
| 36a8868f94 | |||
| fe3e5d6a3d | |||
| 2f3bcaf124 | |||
| c6684d5146 | |||
| f6cb934ffb | |||
| 9625258942 | |||
| 34637e383a | |||
| 0bfa6ac329 | |||
| 2c3261de74 | |||
| c2e6f294ea | |||
| 41e94695f0 | |||
| c6b4ea9929 | |||
| 9dbf5d56f5 | |||
| 64b5bb548b | |||
| 261c8e0811 | |||
| 4476cdcbbc | |||
| 1714681532 | |||
| 314c7960d1 | 
							
								
								
									
										10
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.editorconfig
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
root = true
 | 
			
		||||
 | 
			
		||||
[*]
 | 
			
		||||
end_of_line = lf
 | 
			
		||||
insert_final_newline = true
 | 
			
		||||
trim_trailing_whitespace = true
 | 
			
		||||
 | 
			
		||||
[*.nix]
 | 
			
		||||
indent_style = space
 | 
			
		||||
indent_size = 2
 | 
			
		||||
							
								
								
									
										1
									
								
								.git-blame-ignore-revs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.git-blame-ignore-revs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
e00008da1afe0d760badd34bbeddff36bb08c475
 | 
			
		||||
							
								
								
									
										9
									
								
								base.nix
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								base.nix
									
									
									
									
									
								
							@@ -76,10 +76,19 @@
 | 
			
		||||
  # Trusted users on the nix builder machines
 | 
			
		||||
  users.groups."nix-builder-users".name = "nix-builder-users";
 | 
			
		||||
 | 
			
		||||
  # Let's not thermal throttle
 | 
			
		||||
  services.thermald.enable = lib.mkIf (lib.all (x: x) [
 | 
			
		||||
      (config.nixpkgs.system == "x86_64-linux")
 | 
			
		||||
      (!config.boot.isContainer or false)
 | 
			
		||||
    ]) true;
 | 
			
		||||
 | 
			
		||||
  services.openssh = {
 | 
			
		||||
    enable = true;
 | 
			
		||||
    extraConfig = ''
 | 
			
		||||
      PubkeyAcceptedAlgorithms=+ssh-rsa
 | 
			
		||||
      Match Group wheel
 | 
			
		||||
        PasswordAuthentication no
 | 
			
		||||
      Match All
 | 
			
		||||
    '';
 | 
			
		||||
    settings.PermitRootLogin = "yes";
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								flake.nix
									
									
									
									
									
								
							@@ -37,8 +37,8 @@
 | 
			
		||||
      "aarch64-linux"
 | 
			
		||||
      "aarch64-darwin"
 | 
			
		||||
    ];
 | 
			
		||||
    forAllSystems = f: nixlib.genAttrs systems (system: f system);
 | 
			
		||||
    allMachines = nixlib.mapAttrsToList (name: _: name) self.nixosConfigurations;
 | 
			
		||||
    forAllSystems = f: nixlib.genAttrs systems f;
 | 
			
		||||
    allMachines = builtins.attrNames self.nixosConfigurations;
 | 
			
		||||
    importantMachines = [
 | 
			
		||||
      "bekkalokk"
 | 
			
		||||
      "bicep"
 | 
			
		||||
@@ -47,6 +47,8 @@
 | 
			
		||||
      "ildkule"
 | 
			
		||||
    ];
 | 
			
		||||
  in {
 | 
			
		||||
    inherit inputs;
 | 
			
		||||
 | 
			
		||||
    nixosConfigurations = let
 | 
			
		||||
      unstablePkgs = nixpkgs-unstable.legacyPackages.x86_64-linux;
 | 
			
		||||
      nixosConfig = nixpkgs: name: config: nixpkgs.lib.nixosSystem (nixpkgs.lib.recursiveUpdate
 | 
			
		||||
@@ -124,6 +126,11 @@
 | 
			
		||||
      buskerud = stableNixosConfig "buskerud" { };
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    nixosModules = {
 | 
			
		||||
      snakeoil-certs = ./modules/snakeoil-certs.nix;
 | 
			
		||||
      snappymail = ./modules/snappymail.nix;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    devShells = forAllSystems (system: {
 | 
			
		||||
      default = nixpkgs.legacyPackages.${system}.callPackage ./shell.nix { };
 | 
			
		||||
    });
 | 
			
		||||
 
 | 
			
		||||
@@ -58,6 +58,14 @@ in {
 | 
			
		||||
      service = {
 | 
			
		||||
        DISABLE_REGISTRATION = true;
 | 
			
		||||
        ENABLE_NOTIFY_MAIL = true;
 | 
			
		||||
 | 
			
		||||
        # Not a very commonly used feature, make opt-in
 | 
			
		||||
        DEFAULT_ENABLE_TIMETRACKING = false;
 | 
			
		||||
 | 
			
		||||
        # Everyone here are contributors
 | 
			
		||||
        DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME = false;
 | 
			
		||||
 | 
			
		||||
        DEFAULT_ORG_MEMBER_VISIBLE = true;
 | 
			
		||||
      };
 | 
			
		||||
      admin.DEFAULT_EMAIL_NOTIFICATIONS = "onmention";
 | 
			
		||||
      session.COOKIE_SECURE = true;
 | 
			
		||||
@@ -135,10 +143,16 @@ in {
 | 
			
		||||
    script = let
 | 
			
		||||
      logo-svg = ../../../../assets/logo_blue_regular.svg;
 | 
			
		||||
      logo-png = ../../../../assets/logo_blue_regular.png;
 | 
			
		||||
      extraLinks = pkgs.writeText "gitea-extra-links.tmpl" ''
 | 
			
		||||
        <a class="item" href="https://www.pvv.ntnu.no/">PVV</a>
 | 
			
		||||
        <a class="item" href="https://wiki.pvv.ntnu.no/">Wiki</a>
 | 
			
		||||
        <a class="item" href="https://git.pvv.ntnu.no/Drift/-/projects/4">Tokyo Drift Issues</a>
 | 
			
		||||
      '';
 | 
			
		||||
    in ''
 | 
			
		||||
      install -Dm444 ${logo-svg} ${cfg.customDir}/public/assets/img/logo.svg
 | 
			
		||||
      install -Dm444 ${logo-png} ${cfg.customDir}/public/assets/img/logo.png
 | 
			
		||||
      install -Dm444 ${./loading.apng} ${cfg.customDir}/public/assets/img/loading.png
 | 
			
		||||
      install -Dm444 ${extraLinks} ${cfg.customDir}/templates/custom/extra_links.tmpl
 | 
			
		||||
    '';
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -879,7 +879,7 @@ let
 | 
			
		||||
 | 
			
		||||
  inherit (pkgs) pam_krb5 pam_ccreds;
 | 
			
		||||
 | 
			
		||||
  use_ldap = (config.users.ldap.enable && config.users.ldap.loginPam);
 | 
			
		||||
  use_ldap = config.users.ldap.enable && config.users.ldap.loginPam;
 | 
			
		||||
  pam_ldap = if config.users.ldap.daemon.enable then pkgs.nss_pam_ldapd else pkgs.pam_ldap;
 | 
			
		||||
 | 
			
		||||
  # Create a limits.conf(5) file.
 | 
			
		||||
@@ -1510,7 +1510,7 @@ in
 | 
			
		||||
            it complains "Cannot create session: Already running in a
 | 
			
		||||
            session". */
 | 
			
		||||
        runuser-l = { rootOK = true; unixAuth = false; };
 | 
			
		||||
      } // optionalAttrs (config.security.pam.enableFscrypt) {
 | 
			
		||||
      } // optionalAttrs config.security.pam.enableFscrypt {
 | 
			
		||||
        # Allow fscrypt to verify login passphrase
 | 
			
		||||
        fscrypt = {};
 | 
			
		||||
      };
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
  services.mjolnir = {
 | 
			
		||||
    enable = true;
 | 
			
		||||
    pantalaimon.enable = false;
 | 
			
		||||
    homeserverUrl = http://127.0.0.1:8008;
 | 
			
		||||
    homeserverUrl = "http://127.0.0.1:8008";
 | 
			
		||||
    accessTokenFile = config.sops.secrets."matrix/mjolnir/access_token".path;
 | 
			
		||||
    managementRoom = "!gsdeCoWjvYRBrzuiRq:pvv.ntnu.no";
 | 
			
		||||
    protectedRooms = map (a: "https://matrix.to/#/${a}") [
 | 
			
		||||
 
 | 
			
		||||
@@ -143,10 +143,10 @@ in {
 | 
			
		||||
  services.redis.servers."".enable = true;
 | 
			
		||||
 | 
			
		||||
  services.nginx.virtualHosts."matrix.pvv.ntnu.no" = lib.mkMerge [
 | 
			
		||||
  ({
 | 
			
		||||
  {
 | 
			
		||||
    kTLS = true;
 | 
			
		||||
  })
 | 
			
		||||
  ({
 | 
			
		||||
  }
 | 
			
		||||
  {
 | 
			
		||||
    locations."/.well-known/matrix/server" = {
 | 
			
		||||
      return = ''
 | 
			
		||||
        200 '{"m.server": "matrix.pvv.ntnu.no:443"}'
 | 
			
		||||
@@ -156,16 +156,16 @@ in {
 | 
			
		||||
        add_header Access-Control-Allow-Origin *;
 | 
			
		||||
      '';
 | 
			
		||||
    };
 | 
			
		||||
  })
 | 
			
		||||
  ({
 | 
			
		||||
  }
 | 
			
		||||
  {
 | 
			
		||||
    locations = let
 | 
			
		||||
      connectionInfo = w: matrix-lib.workerConnectionResource "metrics" w;
 | 
			
		||||
      socketAddress = w: let c = connectionInfo w; in "${c.host}:${toString (c.port)}";
 | 
			
		||||
      socketAddress = w: let c = connectionInfo w; in "${c.host}:${toString c.port}";
 | 
			
		||||
 | 
			
		||||
      metricsPath = w: "/metrics/${w.type}/${toString w.index}";
 | 
			
		||||
      proxyPath = w: "http://${socketAddress w}/_synapse/metrics";
 | 
			
		||||
    in lib.mapAttrs' (n: v: lib.nameValuePair
 | 
			
		||||
      (metricsPath v) ({
 | 
			
		||||
      (metricsPath v) {
 | 
			
		||||
        proxyPass = proxyPath v;
 | 
			
		||||
        extraConfig = ''
 | 
			
		||||
          allow ${values.hosts.ildkule.ipv4};
 | 
			
		||||
@@ -174,10 +174,10 @@ in {
 | 
			
		||||
          allow ${values.hosts.ildkule.ipv6_global};
 | 
			
		||||
          deny all;
 | 
			
		||||
        '';
 | 
			
		||||
      }))
 | 
			
		||||
      cfg.workers.instances;
 | 
			
		||||
      })
 | 
			
		||||
  ({
 | 
			
		||||
      cfg.workers.instances;
 | 
			
		||||
  }
 | 
			
		||||
  {
 | 
			
		||||
    locations."/metrics/master/1" = {
 | 
			
		||||
      proxyPass = "http://127.0.0.1:9000/_synapse/metrics";
 | 
			
		||||
      extraConfig = ''
 | 
			
		||||
@@ -202,5 +202,5 @@ in {
 | 
			
		||||
            labels = { };
 | 
			
		||||
          }]) + "/";
 | 
			
		||||
    };
 | 
			
		||||
  })];
 | 
			
		||||
  }];
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@
 | 
			
		||||
      ../../misc/metrics-exporters.nix
 | 
			
		||||
 | 
			
		||||
      ../../modules/grzegorz.nix
 | 
			
		||||
      ../../modules/spotifyd.nix
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
  boot.loader.systemd-boot.enable = true;
 | 
			
		||||
 
 | 
			
		||||
@@ -34,13 +34,13 @@ in {
 | 
			
		||||
        {
 | 
			
		||||
          name = "Ildkule Prometheus";
 | 
			
		||||
          type = "prometheus";
 | 
			
		||||
          url = ("http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}");
 | 
			
		||||
          url = "http://${config.services.prometheus.listenAddress}:${toString config.services.prometheus.port}";
 | 
			
		||||
          isDefault = true;
 | 
			
		||||
        }
 | 
			
		||||
        {
 | 
			
		||||
          name = "Ildkule loki";
 | 
			
		||||
          type = "loki";
 | 
			
		||||
          url = ("http://${config.services.loki.configuration.server.http_listen_address}:${toString config.services.loki.configuration.server.http_listen_port}");
 | 
			
		||||
          url = "http://${config.services.loki.configuration.server.http_listen_address}:${toString config.services.loki.configuration.server.http_listen_port}";
 | 
			
		||||
        }
 | 
			
		||||
      ];
 | 
			
		||||
      dashboards.settings.providers = [
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								justfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								justfile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
export GUM_FILTER_HEIGHT := "15"
 | 
			
		||||
nom := `if command -v nom >/dev/null; then echo nom; else echo nix; fi`
 | 
			
		||||
 | 
			
		||||
@_default:
 | 
			
		||||
  just "$(gum choose --ordered --header "Pick a recipie..." $(just --summary --unsorted))"
 | 
			
		||||
 | 
			
		||||
check:
 | 
			
		||||
  nix flake check --keep-going
 | 
			
		||||
 | 
			
		||||
build-machine machine=`just _a_machine`:
 | 
			
		||||
  {{nom}} build .#nixosConfigurations.{{ machine }}.config.system.build.toplevel
 | 
			
		||||
 | 
			
		||||
@update-inputs:
 | 
			
		||||
  nix eval .#inputs --apply builtins.attrNames --json \
 | 
			
		||||
    | jq '.[]' -r \
 | 
			
		||||
    | gum choose --no-limit --height=15 \
 | 
			
		||||
    | xargs nix flake update --commit-lock-file
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
_a_machine:
 | 
			
		||||
  nix eval .#nixosConfigurations --apply builtins.attrNames --json | jq .[] -r | gum filter
 | 
			
		||||
@@ -1,44 +0,0 @@
 | 
			
		||||
{ lib, config, ... }:
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  services.spotifyd.enable = true;
 | 
			
		||||
  # https://docs.spotifyd.rs/config/File.html
 | 
			
		||||
  services.spotifyd.settings = {
 | 
			
		||||
    device_name = "${config.networking.hostName}-spotifyd";
 | 
			
		||||
    device_type = "t_v"; # in ["unknown" "computer" "tablet" "smartphone" "speaker" "t_v"],
 | 
			
		||||
    bitrate = 160; # in [96 160 320]
 | 
			
		||||
    volume_normalisation = true;
 | 
			
		||||
    zeroconf_port = 44677; # instead of user/password
 | 
			
		||||
 | 
			
		||||
    # this is the place you add blinkenlights
 | 
			
		||||
    #on_song_change_hook = "rm -rf / --no-preserve-root";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  systemd.services.spotifyd.serviceConfig = {
 | 
			
		||||
    SupplementaryGroups = [
 | 
			
		||||
      "audio"
 | 
			
		||||
      "pipewire"
 | 
			
		||||
    ];
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  services.avahi.enable = true;
 | 
			
		||||
  services.avahi.publish.enable = true;
 | 
			
		||||
  services.avahi.publish.addresses = true;
 | 
			
		||||
  services.avahi.publish.domain = true;
 | 
			
		||||
  services.avahi.extraServiceFiles.spotifyd = ''
 | 
			
		||||
    <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
 | 
			
		||||
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 | 
			
		||||
    <service-group>
 | 
			
		||||
      <name replace-wildcards="yes">%h</name>
 | 
			
		||||
      <service>
 | 
			
		||||
        <type>_spotify-connect._tcp</type>
 | 
			
		||||
        <port>${builtins.toString config.services.spotifyd.settings.zeroconf_port}</port>
 | 
			
		||||
      </service>
 | 
			
		||||
    </service-group>
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  networking.firewall.allowedTCPPorts = [ config.services.spotifyd.settings.zeroconf_port ];
 | 
			
		||||
  networking.firewall.allowedUDPPorts = [ 5353 ]; # mDNS
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +1,14 @@
 | 
			
		||||
{ pkgs ? import <nixpkgs> {} }:
 | 
			
		||||
pkgs.mkShellNoCC {
 | 
			
		||||
  packages = with pkgs; [
 | 
			
		||||
    just
 | 
			
		||||
    jq
 | 
			
		||||
    gum
 | 
			
		||||
    sops
 | 
			
		||||
    gnupg
 | 
			
		||||
    statix
 | 
			
		||||
    openstackclient
 | 
			
		||||
    editorconfig-checker
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  shellHook = ''
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								statix.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								statix.toml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
ignore = [".direnv"]
 | 
			
		||||
nix_version = '2.18' # '2.4'
 | 
			
		||||
disabled = [
 | 
			
		||||
    # "bool_comparison", # W01
 | 
			
		||||
    # "empty_let_in", # W02
 | 
			
		||||
    "manual_inherit", # W03
 | 
			
		||||
    "manual_inherit_from", # W04
 | 
			
		||||
    # "legacy_let_syntax", # W05
 | 
			
		||||
    "collapsible_let_in", # W06
 | 
			
		||||
    # "eta_reduction", # W07
 | 
			
		||||
    # "useless_parens", # W08
 | 
			
		||||
    "empty_pattern", # W10
 | 
			
		||||
    # "redundant_pattern_bind", # W11
 | 
			
		||||
    # "unquoted_uri", # W12
 | 
			
		||||
    # "deprecated_is_null", # W13
 | 
			
		||||
    # "empty_inherit", # W14
 | 
			
		||||
    # "faster_groupby", # W15
 | 
			
		||||
    # "faster_zipattrswith", # W16
 | 
			
		||||
    # "deprecated_to_path", # W17
 | 
			
		||||
    # "bool_simplification", # W18
 | 
			
		||||
    # "useless_has_attr", # W19
 | 
			
		||||
    "repeated_keys", # W20
 | 
			
		||||
    "empty_list_concat", # W23
 | 
			
		||||
]
 | 
			
		||||
		Reference in New Issue
	
	Block a user