From 8c279674b02ef23927e1bb3a203823a952e40033 Mon Sep 17 00:00:00 2001 From: sstent Date: Wed, 24 Jan 2024 22:36:34 +0000 Subject: [PATCH] sync --- flake.nix | 18 +- home-manager/users/sstent/default.nix | 19 +- home-manager/users/sstent/python-packages.nix | 1 - hosts/binfmt.nix | 59 ++--- hosts/common.nix | 202 +++++++++--------- modules/home-manager/beets/default.nix | 35 +-- modules/nixos/wsl2/default.nix | 22 +- overlays/default.nix | 31 ++- pkgs/beets-originquery/default.nix | 70 +++--- pkgs/default.nix | 1 + pkgs/prometheus-api-client/default.nix | 31 +++ pkgs/python/prometheus-api-client/default.nix | 35 --- 12 files changed, 264 insertions(+), 260 deletions(-) create mode 100644 pkgs/prometheus-api-client/default.nix delete mode 100644 pkgs/python/prometheus-api-client/default.nix diff --git a/flake.nix b/flake.nix index c6e7cc4..d815125 100644 --- a/flake.nix +++ b/flake.nix @@ -72,8 +72,9 @@ config.allowUnfree = true; # forgive me Stallman senpai overlays = extraOverlays ++ (lib.attrValues self.overlays); }; - pkgs = mkPkgs nixpkgs [self.overlay]; - pkgs' = mkPkgs nixpkgs-unstable []; + # pkgs = mkPkgs nixpkgs [self.overlay]; + pkgs = mkPkgs nixpkgs []; + # pkgs' = mkPkgs nixpkgs-unstable []; lib = nixpkgs.lib.extend @@ -87,18 +88,17 @@ // home-manager.lib); in { lib = lib.my; - packages."${system}" = - mapModules ./pkgs (p: pkgs.callPackage p {}); + packages."${system}" = mapModules ./pkgs (p: pkgs.callPackage p {}); formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra; devShell."${system}" = import ./shell.nix {inherit pkgs;}; - overlay = final: prev: { - unstable = pkgs'; - my = self.packages."${system}"; - keybase = pkgs'.keybase; - }; + # overlay = final: prev: { + # unstable = pkgs'; + # my = self.packages."${system}"; + # keybase = pkgs'.keybase; + # }; overlays = import ./overlays {inherit inputs;}; diff --git a/home-manager/users/sstent/default.nix b/home-manager/users/sstent/default.nix index 90ec359..26025a5 100644 --- a/home-manager/users/sstent/default.nix +++ b/home-manager/users/sstent/default.nix @@ -31,11 +31,9 @@ # home.file."/home/sstent/justfile".source = ./justfile; home.file."/home/sstent/justfile".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/vmimages/dotfiles/${config.home.username}/justfile"; home.file."/home/sstent/.config/bash-completions/nomad_.bash".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/vmimages/dotfiles/${config.home.username}/nomad_.bash"; - # home.file."/home/sstent/.config/beets/test".source = config.lib.file.mkOutOfStoreSymlink /run/user/1000/secrets/test; - # Let Home Manager install and manage itself. programs.home-manager.enable = true; home.packages = with pkgs; [ @@ -65,7 +63,8 @@ # deploy-rs gnumake unstable.keybase -]; + # my.prometheus-api-client + ]; custom = { ssh-proxy.enable = false; @@ -107,7 +106,7 @@ export LANG=C - for command in $({ just --summary; just -l | grep "# alias for " | awk "{print \$1}"; } | tr " " "\\n" | sed "/^default\$/d" | xargs); + for command in $({ just --summary; just -l | grep "# alias for " | awk "{print \$1}"; } | tr " " "\\n" | sed "/^default\$/d" | xargs); do alias $command="just $command" done @@ -124,9 +123,9 @@ ssh = { enable = true; extraConfig = '' - StrictHostKeyChecking no - UpdateHostKeys yes - identityFile = "~/.ssh/id_rsa" + StrictHostKeyChecking no + UpdateHostKeys yes + identityFile = "~/.ssh/id_rsa" ''; matchBlocks = { # "*" = { @@ -145,7 +144,7 @@ }; }; ##pr2100 - "192.168.1.109" = { + "192.168.1.109" = { user = "sshd"; extraOptions = { StrictHostKeyChecking = "no"; @@ -154,7 +153,7 @@ }; }; ##USG - "192.168.1.1" = { + "192.168.1.1" = { user = "fbleagh"; extraOptions = { StrictHostKeyChecking = "no"; @@ -162,7 +161,7 @@ PubkeyAcceptedKeyTypes = "+ssh-rsa"; ##needed to allow the USG to login with ssh key }; }; - "router" = { + "router" = { user = "fbleagh"; extraOptions = { StrictHostKeyChecking = "no"; diff --git a/home-manager/users/sstent/python-packages.nix b/home-manager/users/sstent/python-packages.nix index d4df215..096a117 100644 --- a/home-manager/users/sstent/python-packages.nix +++ b/home-manager/users/sstent/python-packages.nix @@ -5,5 +5,4 @@ pkgs.python3.withPackages (p: setuptools # setup.py paramiko # ssh library prometheus-api-client - ]) diff --git a/hosts/binfmt.nix b/hosts/binfmt.nix index b87b097..e64d747 100644 --- a/hosts/binfmt.nix +++ b/hosts/binfmt.nix @@ -1,26 +1,33 @@ - -{ lib, inputs, outputs, pkgs, config, ... }: -# Define qemu-arm-static source. -let qemu-arm-static = pkgs.stdenv.mkDerivation { - name = "qemu-arm-static"; - src = builtins.fetchurl { - url = "https://github.com/multiarch/qemu-user-static/releases/download/v6.1.0-8/qemu-arm-static"; - sha256 = "06344d77d4f08b3e1b26ff440cb115179c63ca8047afb978602d7922a51231e3"; - }; - dontUnpack = true; - installPhase = "install -D -m 0755 $src $out/bin/qemu-arm-static"; -}; -in { - # Enable binfmt emulation of extra binary formats (armv7l-linux, for exmaple). - boot.binfmt.registrations.arm = { - interpreter = "${qemu-arm-static}/bin/qemu-arm-static"; - magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00''; - mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff''; - }; - - # Define additional settings for nix. - nix.extraOptions = '' - extra-platforms = armv7l-linux aarch64-linux - ''; - nix.settings.extra-sandbox-paths = [ "/run/binfmt/arm=${qemu-arm-static}/bin/qemu-arm-static" ]; -} +{ + lib, + inputs, + outputs, + pkgs, + config, + ... +}: +# Define qemu-arm-static source. +let + qemu-arm-static = pkgs.stdenv.mkDerivation { + name = "qemu-arm-static"; + src = builtins.fetchurl { + url = "https://github.com/multiarch/qemu-user-static/releases/download/v6.1.0-8/qemu-arm-static"; + sha256 = "06344d77d4f08b3e1b26ff440cb115179c63ca8047afb978602d7922a51231e3"; + }; + dontUnpack = true; + installPhase = "install -D -m 0755 $src $out/bin/qemu-arm-static"; + }; +in { + # Enable binfmt emulation of extra binary formats (armv7l-linux, for exmaple). + boot.binfmt.registrations.arm = { + interpreter = "${qemu-arm-static}/bin/qemu-arm-static"; + magicOrExtension = ''\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00''; + mask = ''\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x00\xff\xfe\xff\xff\xff''; + }; + + # Define additional settings for nix. + nix.extraOptions = '' + extra-platforms = armv7l-linux aarch64-linux + ''; + nix.settings.extra-sandbox-paths = ["/run/binfmt/arm=${qemu-arm-static}/bin/qemu-arm-static"]; +} diff --git a/hosts/common.nix b/hosts/common.nix index 69598d6..d11bfac 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -1,101 +1,101 @@ -# This file (and the global directory) holds config that i use on all hosts -{ - lib, - inputs, - outputs, - pkgs, - config, - ... -}: { - imports = - [ - inputs.home-manager.nixosModules.home-manager - inputs.sops-nix.nixosModules.sops - ] - ++ (builtins.attrValues outputs.nixosModules); - - ###dotfiles path variable - options._dotfiles = lib.mkOption { - type = lib.types.str; - default = "${inputs.self}/home-manager/dotfiles"; - description = "Path to the dotfiles in this repository"; - }; - - ###secrets path variable - options._secrets = lib.mkOption { - type = lib.types.str; - default = "/run/user/1000/secrets"; - description = "Path to the Secrets runtime"; - }; - - ###secretstore path variable - options._secretstore = lib.mkOption { - type = lib.types.str; - default = "${inputs.self}/secrets"; - description = "Path to the Secrets storage"; - }; - - config = { - system.stateVersion = "23.05"; - - sops = { - defaultSopsFile = "${config._secretstore}/host-secrets.yaml"; - age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"]; - }; - - home-manager = { - useUserPackages = true; - extraSpecialArgs = {inherit inputs outputs;}; - sharedModules = [ - inputs.sops-nix.homeManagerModules.sops - ]; - }; - - nixpkgs.config.allowUnfree = true; - programs.fuse.userAllowOther = true; - security.sudo.wheelNeedsPassword = false; - virtualisation.docker.enable = true; - - # nixpkgs.overlays = overlays; - # Enable nix flakes - nix.package = pkgs.nixFlakes; - nix.extraOptions = '' - experimental-features = nix-command flakes - ''; - nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"]; - # nix.nixPath = [ "nixpkgs=pkgs.outPath" ]; - networking.search = ["node.dc1.consul" "service.dc1.consul"]; - networking.nameservers = ["192.168.1.1" "1.1.1.1"]; - # Enable networking - networking.networkmanager.enable = true; - -# Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "en_US.UTF-8"; - LC_IDENTIFICATION = "en_US.UTF-8"; - LC_MEASUREMENT = "en_US.UTF-8"; - LC_MONETARY = "en_US.UTF-8"; - LC_NAME = "en_US.UTF-8"; - LC_PAPER = "en_US.UTF-8"; - LC_TELEPHONE = "en_US.UTF-8"; - }; - - #services.envfs.enable = true; - environment.systemPackages = [ - pkgs.git - pkgs.home-manager - pkgs.sops - pkgs.ssh-to-age - pkgs.age - pkgs.bitwarden-cli - ]; - - nix.gc = { - automatic = true; # Enable the automatic garbage collector - dates = "03:15"; # When to run the garbage collector - options = "-d"; # Arguments to pass to nix-collect-garbage - }; - }; -} +# This file (and the global directory) holds config that i use on all hosts +{ + lib, + inputs, + outputs, + pkgs, + config, + ... +}: { + imports = + [ + inputs.home-manager.nixosModules.home-manager + inputs.sops-nix.nixosModules.sops + ] + ++ (builtins.attrValues outputs.nixosModules); + + ###dotfiles path variable + options._dotfiles = lib.mkOption { + type = lib.types.str; + default = "${inputs.self}/home-manager/dotfiles"; + description = "Path to the dotfiles in this repository"; + }; + + ###secrets path variable + options._secrets = lib.mkOption { + type = lib.types.str; + default = "/run/user/1000/secrets"; + description = "Path to the Secrets runtime"; + }; + + ###secretstore path variable + options._secretstore = lib.mkOption { + type = lib.types.str; + default = "${inputs.self}/secrets"; + description = "Path to the Secrets storage"; + }; + + config = { + system.stateVersion = "23.05"; + + sops = { + defaultSopsFile = "${config._secretstore}/host-secrets.yaml"; + age.sshKeyPaths = ["/etc/ssh/ssh_host_ed25519_key"]; + }; + + home-manager = { + useUserPackages = true; + extraSpecialArgs = {inherit inputs outputs;}; + sharedModules = [ + inputs.sops-nix.homeManagerModules.sops + ]; + }; + + nixpkgs.config.allowUnfree = true; + programs.fuse.userAllowOther = true; + security.sudo.wheelNeedsPassword = false; + virtualisation.docker.enable = true; + + # nixpkgs.overlays = overlays; + # Enable nix flakes + nix.package = pkgs.nixFlakes; + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"]; + # nix.nixPath = [ "nixpkgs=pkgs.outPath" ]; + networking.search = ["node.dc1.consul" "service.dc1.consul"]; + networking.nameservers = ["192.168.1.1" "1.1.1.1"]; + # Enable networking + networking.networkmanager.enable = true; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + }; + + #services.envfs.enable = true; + environment.systemPackages = [ + pkgs.git + pkgs.home-manager + pkgs.sops + pkgs.ssh-to-age + pkgs.age + pkgs.bitwarden-cli + ]; + + nix.gc = { + automatic = true; # Enable the automatic garbage collector + dates = "03:15"; # When to run the garbage collector + options = "-d"; # Arguments to pass to nix-collect-garbage + }; + }; +} diff --git a/modules/home-manager/beets/default.nix b/modules/home-manager/beets/default.nix index 5a3ff64..0893377 100644 --- a/modules/home-manager/beets/default.nix +++ b/modules/home-manager/beets/default.nix @@ -18,7 +18,6 @@ in { config = mkIf cfg.enable { home.packages = [ pkgs.ffmpeg # for replaygain - ]; sops = { @@ -29,7 +28,14 @@ in { programs.beets = { enable = true; - package = (pkgs.beets.override { pluginOverrides = { originquery = {enable = true; propagatedBuildInputs = [ pkgs.beets-originquery ]; }; };}); + package = pkgs.beets.override { + pluginOverrides = { + originquery = { + enable = true; + propagatedBuildInputs = [pkgs.beets-originquery]; + }; + }; + }; settings = { album_fields = { artist_grouping = '' @@ -131,25 +137,24 @@ in { format_item = "$albumartist - $album [$albumtype]$atype: $track/$tracktotal $title"; }; musicbrainz = { - extra_tags= ["year" "catalognum" "country" "media" "label"]; + extra_tags = ["year" "catalognum" "country" "media" "label"]; pass = "7ANCLPczDNFn6Sf65vdZ"; user = "shapechecker"; }; original_date = true; - originquery = { - origin_file = "origin.yaml"; + originquery = { + origin_file = "origin.yaml"; - tag_patterns = { - media = ''$.Media''; - year = ''$."Edition year"''; - label = ''$."Record label"''; - catalognum = ''$."Catalog number"''; - albumdisambig = ''$.Edition''; - }; - - use_origin_on_conflict = true; - }; + tag_patterns = { + media = ''$.Media''; + year = ''$."Edition year"''; + label = ''$."Record label"''; + catalognum = ''$."Catalog number"''; + albumdisambig = ''$.Edition''; + }; + use_origin_on_conflict = true; + }; paths = { "albumtype:soundtrack" = "Soundtracks/$albumartist - $album%aunique{} ($year)/$myDisc$track - $artist - $title"; diff --git a/modules/nixos/wsl2/default.nix b/modules/nixos/wsl2/default.nix index 6aead3e..de98c1c 100644 --- a/modules/nixos/wsl2/default.nix +++ b/modules/nixos/wsl2/default.nix @@ -18,17 +18,17 @@ in { wsl.extraBin = [ # Required by VS Code's Remote WSL extension # Required by VS Code's Remote WSL extension - { src = "${pkgs.coreutils}/bin/dirname"; } - { src = "${pkgs.coreutils}/bin/readlink"; } - { src = "${pkgs.coreutils}/bin/uname"; } - { src = "${pkgs.coreutils}/bin/mkdir"; } - { src = "${pkgs.coreutils}/bin/rm"; } - { src = "${pkgs.coreutils}/bin/wc"; } - { src = "${pkgs.coreutils}/bin/date"; } - { src = "${pkgs.coreutils}/bin/mv"; } - { src = "${pkgs.coreutils}/bin/sleep"; } - { src = "${pkgs.gnutar}/bin/tar"; } - { src = "${pkgs.gzip}/bin/gzip"; } + {src = "${pkgs.coreutils}/bin/dirname";} + {src = "${pkgs.coreutils}/bin/readlink";} + {src = "${pkgs.coreutils}/bin/uname";} + {src = "${pkgs.coreutils}/bin/mkdir";} + {src = "${pkgs.coreutils}/bin/rm";} + {src = "${pkgs.coreutils}/bin/wc";} + {src = "${pkgs.coreutils}/bin/date";} + {src = "${pkgs.coreutils}/bin/mv";} + {src = "${pkgs.coreutils}/bin/sleep";} + {src = "${pkgs.gnutar}/bin/tar";} + {src = "${pkgs.gzip}/bin/gzip";} ]; programs.nix-ld = { enable = true; diff --git a/overlays/default.nix b/overlays/default.nix index f566158..4412354 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,31 +1,28 @@ # This file defines overlays +# ex {inputs, ...}: { # This one brings our custom packages from the 'pkgs' directory + ## this overrides the 'my.' strcuture additions = final: _prev: import ../pkgs {pkgs = final;}; # This one contains whatever you want to overlay # You can change versions, add patches, set compilation flags, anything really. # https://nixos.wiki/wiki/Overlays modifications = final: prev: { - # example = prev.example.overrideAttrs (oldAttrs: rec { - # ... - # }); - - pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ - ( - python-final: python-prev: - { - prometheus-api-client = python-final.callPackage ../pkgs/python/prometheus-api-client { }; - } - ) - ]; - - - + pythonPackagesExtensions = + prev.pythonPackagesExtensions + ++ [ + ( + python-final: python-prev: { + prometheus-api-client = python-final.callPackage ../pkgs/prometheus-api-client {}; + } + ) + ]; + keybase = final.unstable.keybase; }; - # When applied, the unstable nixpkgs set (declared in the flake inputs) will - # be accessible through 'pkgs.unstable' + #When applied, the unstable nixpkgs set (declared in the flake inputs) will + #be accessible through 'pkgs.unstable' unstable-packages = final: _prev: { unstable = import inputs.nixpkgs-unstable { system = final.system; diff --git a/pkgs/beets-originquery/default.nix b/pkgs/beets-originquery/default.nix index 2fa530f..86b1e98 100644 --- a/pkgs/beets-originquery/default.nix +++ b/pkgs/beets-originquery/default.nix @@ -1,35 +1,35 @@ -{ python3Packages -, fetchFromGitHub -, beets -, lib -}: - -with python3Packages; -buildPythonPackage rec { - pname = "beets-originquery"; - version = "unstable-2022-03-11"; - - src = fetchFromGitHub { - owner = "x1ppy"; - repo = "beets-originquery"; - rev = "c353e2b68804cb4dabca0f0f177cee1137888ca4"; - hash = "sha256-vNROKZgCoWtoou9B8hpJwl4Yf6TzQU0TbKJUd94v7vk="; - }; - - nativeBuildInputs = [ - beets - setuptools-scm - ]; - - propagatedBuildInputs = [ jsonpath_rw ]; - - # There's no test - doCheck = false; - - pythonImportsCheck = [ "beetsplug.originquery" ]; - - meta = { - description = "Plugin for beets that improves album matching"; - homepage = "https://github.com/x1ppy/beets-originquery"; - }; -} \ No newline at end of file +{ + python3Packages, + fetchFromGitHub, + beets, + lib, +}: +with python3Packages; + buildPythonPackage rec { + pname = "beets-originquery"; + version = "unstable-2022-03-11"; + + src = fetchFromGitHub { + owner = "x1ppy"; + repo = "beets-originquery"; + rev = "c353e2b68804cb4dabca0f0f177cee1137888ca4"; + hash = "sha256-vNROKZgCoWtoou9B8hpJwl4Yf6TzQU0TbKJUd94v7vk="; + }; + + nativeBuildInputs = [ + beets + setuptools-scm + ]; + + propagatedBuildInputs = [jsonpath_rw]; + + # There's no test + doCheck = false; + + pythonImportsCheck = ["beetsplug.originquery"]; + + meta = { + description = "Plugin for beets that improves album matching"; + homepage = "https://github.com/x1ppy/beets-originquery"; + }; + } diff --git a/pkgs/default.nix b/pkgs/default.nix index 8ba999a..c410fee 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,4 +4,5 @@ # example = pkgs.callPackage ./example { }; npiperelay = pkgs.callPackage ./npiperelay {}; beets-originquery = pkgs.callPackage ./beets-originquery {}; + prometheus-api-client = pkgs.callPackage ./prometheus-api-client {}; } diff --git a/pkgs/prometheus-api-client/default.nix b/pkgs/prometheus-api-client/default.nix new file mode 100644 index 0000000..52d91f1 --- /dev/null +++ b/pkgs/prometheus-api-client/default.nix @@ -0,0 +1,31 @@ +{ + python3Packages, + fetchurl, + lib, +}: +with python3Packages; + buildPythonPackage rec { + pname = "prometheus-api-client"; + version = "0.5.4"; + src = fetchurl { + url = "https://pypi.org/packages/source/p/prometheus-api-client/prometheus-api-client-0.5.4.tar.gz"; + sha256 = "sha256-OFaBB+GCqibyJZn3lCFeo93l7NPvFJRO72FO6qRsm2o="; + }; + + doCheck = false; + pythonImportsCheck = ["prometheus_api_client"]; + propagatedBuildInputs = [ + matplotlib + numpy + pandas + requests + dateparser + httmock + ]; + + meta = with lib; { + description = "A python wrapper for the prometheus http api"; + homepage = "https://github.com/4n4nd/prometheus-api-client-python"; + licence = licences.mit; + }; + } diff --git a/pkgs/python/prometheus-api-client/default.nix b/pkgs/python/prometheus-api-client/default.nix deleted file mode 100644 index 3e40086..0000000 --- a/pkgs/python/prometheus-api-client/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ lib, python3, pkgs, callPackage, fetchurl,python3Packages, ... }: - -let - pname = "prometheus-api-client"; - version = "0.5.4"; - src = fetchurl { - url = "https://pypi.org/packages/source/p/prometheus-api-client/prometheus-api-client-0.5.4.tar.gz"; - sha256 = "sha256-OFaBB+GCqibyJZn3lCFeo93l7NPvFJRO72FO6qRsm2o="; - }; - -in - -python3.pkgs.buildPythonPackage { - pname = pname; - version = version; - src = src; - - - doCheck = false; - - propagatedBuildInputs = with pkgs.python3Packages; [ - matplotlib - numpy - pandas - requests - dateparser - httmock - ]; - - meta = with lib; { - description = "A python wrapper for the prometheus http api"; - homepage = "https://github.com/4n4nd/prometheus-api-client-python"; - licence = licences.mit; - }; -} \ No newline at end of file