diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml deleted file mode 100644 index 5693a13..0000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,38 +0,0 @@ -# yamllint disable rule:document-start -name: CI -"on": - push: - branches: - - main - pull_request: - workflow_dispatch: -permissions: - contents: read -jobs: - ci: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v7 - - name: Install Nix - uses: cachix/install-nix-action@v31 - with: - # yamllint disable rule:line-length - extra_nix_config: | - experimental-features = nix-command flakes - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - substituters = https://cache.nixos.org https://adam01110-nur.cachix.org/ - trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= adam01110-nur.cachix.org-1:43B8awTREG19aQ20luDD9BkxijKG/Q7hf8voMzS1X9I= - # yamllint enable rule:line-length - - name: Restore and save Nix store - uses: nix-community/cache-nix-action@v7 - with: - primary-key: >- - nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} - restore-prefixes-first-match: | - nix-${{ runner.os }}- - gc-max-store-size-linux: 2G - - name: Run checks - env: - NIXPKGS_ALLOW_UNFREE: "1" - run: nix flake check --impure diff --git a/.github/workflows/update-flake-lock.yml b/.github/workflows/update-flake-lock.yml deleted file mode 100644 index 79dd563..0000000 --- a/.github/workflows/update-flake-lock.yml +++ /dev/null @@ -1,25 +0,0 @@ -# yamllint disable rule:document-start -name: update-flake-lock -'on': - workflow_dispatch: - schedule: - - cron: "0 0 * * 5" -permissions: - contents: write - pull-requests: write -jobs: - lockfile: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v7 - - name: Install Nix - uses: cachix/install-nix-action@v31 - with: - nix_path: nixpkgs=channel:nixos-unstable - - name: Update flake.lock - uses: DeterminateSystems/update-flake-lock@v28 - with: - sign-commits: true - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} diff --git a/README.md b/README.md index b71d277..a214fd7 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,11 @@ Personal Nix packages, modules, and plugin builds that I want available outside my main config. - [![Checks](https://img.shields.io/github/actions/workflow/status/adam01110/nur/checks.yml?branch=main&style=flat-square&label=Checks&labelColor=504945&color=cc241d)](https://github.com/adam01110/nur/actions/workflows/checks.yml) [![Build](https://img.shields.io/github/actions/workflow/status/adam01110/nur/build.yml?branch=main&style=flat-square&label=Build&labelColor=504945&color=cc241d)](https://github.com/adam01110/nur/actions/workflows/build.yml) [![Repo Size](https://img.shields.io/github/repo-size/adam01110/nur?style=flat-square&label=repo%20size&labelColor=504945&color=3c3836)](https://github.com/adam01110/nur) [![Cachix](https://img.shields.io/badge/cachix-adam01110--nur-689d6a?style=flat-square&labelColor=504945&color=689d6a)](https://adam01110-nur.cachix.org)
[![NUR](https://img.shields.io/badge/NUR-adam0-458588?style=flat-square&labelColor=504945&color=458588)](https://github.com/nix-community/NUR) - [![Flakes](https://img.shields.io/badge/Nix-flakes-b16286?style=flat-square&labelColor=504945&color=b16286)](https://nixos.wiki/wiki/Flakes) [Usage](#usage) - [Maintenance](#maintenance) - [Layout](#layout) @@ -20,53 +18,36 @@ This is my small NUR repo for packages that either are not in nixpkgs, need chan ## Usage -Add the repo as a flake input: +Use the repository through NUR: ```nix -{ - inputs.adam0-nur.url = "github:adam01110/nur"; -} -``` - -Then use packages from the flake output for your system: - -```nix -{ - inputs, - pkgs, - ... -}: let - nurPkgs = inputs.adam0-nur.packages.${pkgs.stdenv.hostPlatform.system}; -in { +{pkgs, ...}: { home.packages = [ - nurPkgs.gruvbox-plus-icons - nurPkgs.bibata-modern-cursors-gruvbox-dark + pkgs.nur.repos.adam0.gruvbox-plus-icons + pkgs.nur.repos.adam0.tg ]; } ``` -For classic NUR usage, import it like any other NUR repository: +It can also be imported directly: ```nix -import inputs.adam0-nur { inherit pkgs; } +import (builtins.fetchTarball "https://github.com/adam01110/nur/archive/main.tar.gz") { + inherit pkgs; +} ``` ## Maintenance -This repo is intentionally automated because I do not want package bumps to become fulltime job. - - `build.yml` evaluates and builds cacheable outputs against unstable and stable nixpkgs channels. - `update-packages.yml` runs `python3 -m updater` and opens a signed pull request when package versions move. -- `update-flake-lock.yml` refreshes `flake.lock` weekly. -- `treefmt-nix` keeps formatting consistent with the rest of my Nix repos. ## Layout | Path | Contents | | --- | --- | | `pkgs/` | Package definitions and grouped package sets | -| `hm-modules/` | Home Manager modules exported by the flake | -| `flake/` | Flake parts for packages, formatting, and dev shell wiring | +| `hm-modules/` | Home Manager modules | | `updater/` | Python package updater used by CI | | `ci.nix` | Build/cache selection for CI | | `default.nix` | Classic NUR export surface | diff --git a/default.nix b/default.nix index ba69b6b..20fd31f 100644 --- a/default.nix +++ b/default.nix @@ -52,8 +52,8 @@ in # keep-sorted start gotifyPlugins = recurseIntoAttrs (callPackage ./pkgs/gotify-server/plugins {inherit (allPackages) gotify-server;}); - hyprlandPlugins = recurseCallPackage ./pkgs/hyprland-plugins; - spicetifyExtensions = recurseCallPackage ./pkgs/spicetify-extensions; + hyprlandPlugins = recurseCallPackage ./pkgs/hyprland/plugins; + spicetifyExtensions = recurseCallPackage ./pkgs/spicetify/extensions; yaziPlugins = recurseCallPackage ./pkgs/yazi-plugins; # keep-sorted end } diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 3c39c7a..0000000 --- a/flake.lock +++ /dev/null @@ -1,131 +0,0 @@ -{ - "nodes": { - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1767039857, - "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1782949081, - "narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "import-tree": { - "locked": { - "lastModified": 1784254960, - "narHash": "sha256-iI88R3wHz8wTKQb5orvpc51L/Xr64AJyxid/0MKa/b8=", - "owner": "vic", - "repo": "import-tree", - "rev": "4ebb10ae17d5f1ad366e7aef5b92cb8eecf24f69", - "type": "github" - }, - "original": { - "owner": "vic", - "repo": "import-tree", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1784555310, - "narHash": "sha256-/FCliTPgiuV1owejZFNx3Ch9irdvkOfOFl+HHZ+DrtM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "421eebfd0ec7bccd4abe826ce62d7e6e83129493", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1782614948, - "narHash": "sha256-ePjCwr1sNm9NYUqywL7QfK3JnlS015msC+eBu2zKlp8=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "db3f255737b94216eb71cce308e2912cf6bc2d7c", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-compat": "flake-compat", - "flake-parts": "flake-parts", - "import-tree": "import-tree", - "nixpkgs": "nixpkgs", - "systems": "systems", - "treefmt-nix": "treefmt-nix" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1784369104, - "narHash": "sha256-47cxbcZODibHv3rELFQ9vZly0vUNkND/atn/U7HLeb0=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "df3c0640565d04a0261253cdd89fce78ec50168a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index fe3621a..0000000 --- a/flake.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - description = "My personal NUR repository"; - - inputs = { - # keep-sorted start block=yes newline_separated=yes - flake-compat = { - url = "github:edolstra/flake-compat"; - flake = false; - }; - - flake-parts.url = "github:hercules-ci/flake-parts"; - - import-tree.url = "github:vic/import-tree"; - - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - systems.url = "github:nix-systems/default"; - - treefmt-nix = { - url = "github:numtide/treefmt-nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - # keep-sorted end - }; - - outputs = inputs: - inputs.flake-parts.lib.mkFlake {inherit inputs;} { - systems = import inputs.systems; - imports = [(inputs.import-tree ./flake)]; - }; -} diff --git a/flake/packages.nix b/flake/packages.nix deleted file mode 100644 index e3a6b57..0000000 --- a/flake/packages.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - perSystem = {pkgs, ...}: let - inherit (pkgs) lib; - legacy = import ../default.nix {inherit pkgs;}; - packages = lib.filterAttrs (_: lib.isDerivation) legacy; - in { - legacyPackages = legacy; - inherit packages; - }; -} diff --git a/flake/treefmt.nix b/flake/treefmt.nix deleted file mode 100644 index e1a5082..0000000 --- a/flake/treefmt.nix +++ /dev/null @@ -1,29 +0,0 @@ -{inputs, ...}: { - imports = [inputs.treefmt-nix.flakeModule]; - - perSystem = _: { - treefmt.programs = { - # keep-sorted start - alejandra.enable = true; - deadnix.enable = true; - nixf-diagnose.enable = true; - statix.enable = true; - # keep-sorted end - - ruff-check = { - enable = true; - extendSelect = ["I"]; - }; - ruff-format.enable = true; - - rumdl-format.enable = true; - - # keep-sorted start - yamlfmt.enable = true; - yamllint.enable = true; - # keep-sorted end - - keep-sorted.enable = true; - }; - }; -} diff --git a/pkgs/gotify-server/plugins/slack-webhook/default.nix b/pkgs/gotify-server/plugins/slack-webhook/default.nix deleted file mode 100644 index 3cc3867..0000000 --- a/pkgs/gotify-server/plugins/slack-webhook/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ - # keep-sorted start - fetchFromGitHub, - lib, - mkGotifyPlugin, - # keep-sorted end -}: -mkGotifyPlugin { - pname = "slack-webhook"; - version = "0.0.2"; - - src = fetchFromGitHub { - owner = "NilsGriebner"; - repo = "gotify-slack-webhook"; - rev = "0.0.2"; - hash = "sha256-Pehj9WFTcAdFf/RqULdTmYEMhKjYRmos9/5n8/cb1Cw="; - }; - - patchedSourceHash = "sha256-mof+JC04lGT5gxA1JmvlQ+CZ2wAArdoPUlCHtv5bz10="; - vendorHash = "sha256-Pop8R92hfEFZnht7Fd0i990EZwclex8yxu0H5h384Io="; - - meta = { - # keep-sorted start - description = "Gotify plugin that sends push messages to Slack via webhooks"; - homepage = "https://github.com/NilsGriebner/gotify-slack-webhook"; - license = lib.licenses.mit; - # keep-sorted end - }; -} diff --git a/pkgs/gotify-server/plugins/webhooks/default.nix b/pkgs/gotify-server/plugins/webhooks/default.nix deleted file mode 100644 index 1cf1337..0000000 --- a/pkgs/gotify-server/plugins/webhooks/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - # keep-sorted start - fetchgit, - lib, - mkGotifyPlugin, - # keep-sorted end -}: -mkGotifyPlugin { - pname = "webhooks"; - version = "1.1.3"; - - src = fetchgit { - url = "https://git.leon.wtf/leon/gotify-webhooks-plugin.git"; - rev = "0d7d4b25"; - hash = "sha256-UTCgCBBBioKkq1XDP4Uqeu5sd8hbU5RQAgluGNBppqk="; - }; - - patchedSourceHash = "sha256-aKU7TwjuPZP2SzM4021xQwU3FYVKGTuCZfp9+Z7NKXs="; - vendorHash = "sha256-wvFr3/Aqvz2TmdfNb213lOhEeZ4RUN5vy5Dfda+f4ZM="; - - meta = { - # keep-sorted start - description = "Gotify plugin that enables receiving and processing generic webhooks"; - homepage = "https://git.leon.wtf/leon/gotify-webhooks-plugin"; - license = lib.licenses.mit; - # keep-sorted end - }; -} diff --git a/pkgs/hyprland-plugins/default.nix b/pkgs/hyprland-plugins/default.nix deleted file mode 100644 index 1511389..0000000 --- a/pkgs/hyprland-plugins/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - callPackage, - hyprlandPlugins, -}: { - hypr-kinetic-scroll = callPackage ./hypr-kinetic-scroll.nix {inherit (hyprlandPlugins) mkHyprlandPlugin;}; -} diff --git a/pkgs/hyprland/plugins/default.nix b/pkgs/hyprland/plugins/default.nix new file mode 100644 index 0000000..47ccdea --- /dev/null +++ b/pkgs/hyprland/plugins/default.nix @@ -0,0 +1,9 @@ +{ + callPackage, + hyprlandPlugins, +}: { + hypr-kinetic-scroll = callPackage ./hypr-kinetic-scroll {inherit (hyprlandPlugins) mkHyprlandPlugin;}; + + # Lua plugin does not use Hyprland's native plugin builder. + hyprsplit = callPackage ./hyprsplit {}; +} diff --git a/pkgs/hyprland-plugins/hypr-kinetic-scroll.nix b/pkgs/hyprland/plugins/hypr-kinetic-scroll/default.nix similarity index 100% rename from pkgs/hyprland-plugins/hypr-kinetic-scroll.nix rename to pkgs/hyprland/plugins/hypr-kinetic-scroll/default.nix diff --git a/pkgs/hyprsplit/default.nix b/pkgs/hyprland/plugins/hyprsplit/default.nix similarity index 100% rename from pkgs/hyprsplit/default.nix rename to pkgs/hyprland/plugins/hyprsplit/default.nix diff --git a/pkgs/spicetify-extensions/default.nix b/pkgs/spicetify/extensions/default.nix similarity index 100% rename from pkgs/spicetify-extensions/default.nix rename to pkgs/spicetify/extensions/default.nix diff --git a/pkgs/spicetify-extensions/moreLyrics/default.nix b/pkgs/spicetify/extensions/moreLyrics/default.nix similarity index 100% rename from pkgs/spicetify-extensions/moreLyrics/default.nix rename to pkgs/spicetify/extensions/moreLyrics/default.nix diff --git a/pkgs/spicetify-extensions/playlistIcons/default.nix b/pkgs/spicetify/extensions/playlistIcons/default.nix similarity index 100% rename from pkgs/spicetify-extensions/playlistIcons/default.nix rename to pkgs/spicetify/extensions/playlistIcons/default.nix diff --git a/pkgs/spicetify-extensions/volumePercentage/default.nix b/pkgs/spicetify/extensions/volumePercentage/default.nix similarity index 100% rename from pkgs/spicetify-extensions/volumePercentage/default.nix rename to pkgs/spicetify/extensions/volumePercentage/default.nix diff --git a/pkgs/tang/default.nix b/pkgs/tang/default.nix deleted file mode 100644 index 06b9dd8..0000000 --- a/pkgs/tang/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - # keep-sorted start - buildGo125Module, - fetchgit, - lib, - # keep-sorted end -}: -buildGo125Module rec { - pname = "tang"; - version = "0.0.3"; - commit = "b70dd08c7e50d309a9e0364726bb10e0ef5a8698"; - - src = fetchgit { - url = "https://tangled.org/onev.cat/tang"; - tag = "v${version}"; - hash = "sha256-67sM40z9urUB5KxkaiJjRcscCcqdG+WLqjpIxDp1LXg="; - }; - - vendorHash = "sha256-OBKIlZUGbvH6Om5/IicVmpXddROpdsKpJe87YvKZnzo="; - - ldflags = [ - "-X main.version=${version}" - "-X main.commit=${commit}" - ]; - - subPackages = ["cmd/tang"]; - - meta = with lib; { - # keep-sorted start - description = "Command-line client for Tangled"; - homepage = "https://tangled.org/onev.cat/tang"; - license = licenses.mit; - mainProgram = "tang"; - platforms = platforms.unix; - # keep-sorted end - }; -} diff --git a/pkgs/tg/default.nix b/pkgs/tg/default.nix new file mode 100644 index 0000000..2736846 --- /dev/null +++ b/pkgs/tg/default.nix @@ -0,0 +1,60 @@ +{ + # keep-sorted start + buildGo126Module, + fetchgit, + git, + installShellFiles, + lib, + stdenv, + # keep-sorted end +}: +buildGo126Module rec { + pname = "tg"; + version = "0.1.0"; + + src = fetchgit { + url = "https://tangled.org/secluded.site/tg"; + tag = "v${version}"; + hash = "sha256-0ugbaL2wyhLniu8oQc8aKgLb1CWrVJyauvUir/Cc+tA="; + }; + + vendorHash = "sha256-yifZoO8dBh9/oCkVlwYmtXJ+txzfPr8N/D2yMehph8E="; + proxyVendor = true; + + subPackages = ["cmd/tg"]; + + nativeBuildInputs = [installShellFiles]; + nativeCheckInputs = [git]; + + checkPhase = '' + runHook preCheck + go test ./... + runHook postCheck + ''; + + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + manPageDir=$(mktemp -d) + $out/bin/tg man "$manPageDir" + installManPage "$manPageDir"/* + + installShellCompletion --cmd tg \ + --bash <($out/bin/tg completion bash) \ + --fish <($out/bin/tg completion fish) \ + --zsh <($out/bin/tg completion zsh) + ''; + + ldflags = [ + "-s" + "-w" + ]; + + meta = { + # keep-sorted start + description = "Terminal client for Tangled"; + homepage = "https://tangled.org/secluded.site/tg"; + license = lib.licenses.gpl3Plus; + mainProgram = "tg"; + platforms = lib.platforms.unix; + # keep-sorted end + }; +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 9cf1792..0000000 --- a/shell.nix +++ /dev/null @@ -1,19 +0,0 @@ -let - inherit - (builtins) - # keep-sorted start - fromJSON - readFile - # keep-sorted end - ; - - lock = fromJSON (readFile ./flake.lock); - nodeName = lock.nodes.root.inputs.flake-compat; - flakeCompat = fetchTarball { - url = - lock.nodes.${nodeName}.locked.url - or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz"; - sha256 = lock.nodes.${nodeName}.locked.narHash; - }; -in - (import flakeCompat {src = ./.;}).shellNix diff --git a/updater/discovery.py b/updater/discovery.py index 7ed512a..36170cd 100644 --- a/updater/discovery.py +++ b/updater/discovery.py @@ -3,18 +3,16 @@ from __future__ import annotations import logging from collections.abc import Iterable -from .models import PackageRef, SourceKind -from .nix import attr_file_path, flake_attrsets, list_derivations, list_file_attrsets +from .models import PackageRef +from .nix import attr_file_path, list_derivations, list_file_attrsets logger = logging.getLogger(__name__) def discover_packages(system: str) -> list[PackageRef]: refs: list[PackageRef] = [] - for attrset in flake_attrsets(system): - refs.extend(_refs_for_attrset("flake", attrset)) for attrset in list_file_attrsets(): - refs.extend(_refs_for_attrset("file", attrset)) + refs.extend(_refs_for_attrset(attrset)) logger.info("discovered %d package(s) for %s", len(refs), system) return refs @@ -26,21 +24,20 @@ def filter_packages(refs: Iterable[PackageRef], selected: list[str]) -> list[Pac return [ref for ref in refs if ref.attr_path in wanted or ref.attr in wanted] -def _refs_for_attrset(source_kind: SourceKind, attrset: str) -> list[PackageRef]: +def _refs_for_attrset(attrset: str) -> list[PackageRef]: refs: list[PackageRef] = [] - attrs = list_derivations(source_kind, attrset) - logger.info("found %d derivation(s) in %s", len(attrs), attrset) + attrs = list_derivations(attrset) + logger.info("found %d derivation(s) in %s", len(attrs), attrset or "default.nix") for attr in attrs: - file_path = attr_file_path(source_kind, attrset, attr) + file_path = attr_file_path(attrset, attr) if not file_path: logger.info("skipping %s.%s: no source file", attrset, attr) continue refs.append( PackageRef( - source_kind=source_kind, attrset=attrset, attr=attr, - attr_path=f"{attrset}.{attr}", + attr_path=f"{attrset}.{attr}" if attrset else attr, file_path=file_path, ) ) diff --git a/updater/models.py b/updater/models.py index dc5fedc..3e0cee1 100644 --- a/updater/models.py +++ b/updater/models.py @@ -5,13 +5,11 @@ from pathlib import Path from typing import Literal VersionMode = Literal["stable", "branch"] -SourceKind = Literal["flake", "file"] ResultStatus = Literal["updated", "skipped", "invalid", "failed"] @dataclass(frozen=True) class PackageRef: - source_kind: SourceKind attrset: str attr: str attr_path: str diff --git a/updater/nix.py b/updater/nix.py index c5c17c0..7f2b9b4 100644 --- a/updater/nix.py +++ b/updater/nix.py @@ -1,34 +1,25 @@ from __future__ import annotations import json -import re from pathlib import Path -from .models import PackageState, SourceKind +from .models import PackageState from .process import ROOT, run from .versions import version_mode -def nix_eval_attrset(source_kind: SourceKind, attrset: str, apply_expr: str) -> str: - if source_kind == "flake": - command = ["nix", "eval", "--raw", f".#{attrset}", "--apply", apply_expr] +def nix_eval_attrset(attrset: str, apply_expr: str) -> str: + command = ["nix", "eval", "--raw", "--file", "default.nix"] + if attrset: + command.append(attrset) else: - command = [ - "nix", - "eval", - "--raw", - "--file", - "default.nix", - attrset, - "--apply", - apply_expr, - ] + apply_expr = f"f: ({apply_expr}) (f {{}})" + command.extend(["--apply", apply_expr]) return run(command).stdout -def list_derivations(source_kind: SourceKind, attrset: str) -> list[str]: +def list_derivations(attrset: str) -> list[str]: output = nix_eval_attrset( - source_kind, attrset, r""" pkgs: @@ -69,19 +60,12 @@ in """, ] ).stdout - return [line for line in output.splitlines() if line] - + return [""] + [line for line in output.splitlines() if line] -def flake_attrsets(system: str) -> list[str]: - attrset = f"packages.{system}" - result = run(["nix", "eval", "--raw", f".#{attrset}", "--apply", 'pkgs: ""'], check=False) - return [attrset] if result.returncode == 0 else [] - -def read_state(source_kind: SourceKind, attrset: str, attr: str) -> PackageState: +def read_state(attrset: str, attr: str) -> PackageState: escaped = _escape(attr) output = nix_eval_attrset( - source_kind, attrset, f''' pkgs: @@ -109,10 +93,9 @@ pkgs: ) -def attr_file_path(source_kind: SourceKind, attrset: str, attr: str) -> Path | None: +def attr_file_path(attrset: str, attr: str) -> Path | None: escaped = _escape(attr) position = nix_eval_attrset( - source_kind, attrset, f''' pkgs: @@ -124,11 +107,6 @@ pkgs: return None file_name = position.split(":", 1)[0] - if source_kind == "flake": - match = re.match(r"^/nix/store/[^/]+-source(/.*)$", file_name) - if match: - file_name = str(ROOT) + match.group(1) - file_path = Path(file_name) if not file_path.is_relative_to(ROOT) or not file_path.is_file(): return None diff --git a/updater/package_backend.py b/updater/package_backend.py index ade9e9e..da411e2 100644 --- a/updater/package_backend.py +++ b/updater/package_backend.py @@ -30,7 +30,7 @@ def update_package( return UpdateResult(ref.attr_path, "skipped", f"manifest updater owns {manifest}") owned_roots = package_owned_roots(ref.file_path) - before = read_state(ref.source_kind, ref.attrset, ref.attr) + before = read_state(ref.attrset, ref.attr) with FileTransaction(owned_roots) as transaction: try: @@ -40,12 +40,12 @@ def update_package( logger.info("nix-update failed for %s:\n%s", ref.attr_path, error.details) return UpdateResult(ref.attr_path, "skipped", f"nix-update failed: {error}") - after = read_state(ref.source_kind, ref.attrset, ref.attr) + after = read_state(ref.attrset, ref.attr) changed = transaction.new_changed_files() owned_changed, unrelated = paths_owned_by(changed, owned_roots) release_prefix = latest_release_prefix_for_url(after.src_url) if _preserve_unproven_branch_prefix(ref.file_path, before, after, release_prefix): - after = read_state(ref.source_kind, ref.attrset, ref.attr) + after = read_state(ref.attrset, ref.attr) changed = transaction.new_changed_files() owned_changed, unrelated = paths_owned_by(changed, owned_roots) validation = validate_transition( @@ -144,28 +144,16 @@ def _rejected_status(reason: str) -> ResultStatus: def _run_nix_update(ref: PackageRef, version_mode: str, *, timeout: str | None) -> None: - if ref.source_kind == "flake": - command = [ - "nix", - "run", - "nixpkgs#nix-update", - "--", - "--flake", - "--use-github-releases", - f"--version={version_mode}", - ref.attr_path, - ] - else: - command = [ - "nix", - "run", - "nixpkgs#nix-update", - "--", - "-f", - "default.nix", - f"--version={version_mode}", - ref.attr_path, - ] + command = [ + "nix", + "run", + "nixpkgs#nix-update", + "--", + "-f", + "default.nix", + f"--version={version_mode}", + ref.attr_path, + ] run(command, timeout=timeout) @@ -216,16 +204,8 @@ def _last_got_hash(ref: PackageRef, *, timeout: str | None) -> str: def _build_with_fake_hash( ref: PackageRef, *, timeout: str | None ) -> subprocess.CompletedProcess[str]: - if ref.source_kind == "flake": - result = run( - ["nix", "build", f".#{ref.attr_path}", "--no-link"], - timeout=timeout, - check=False, - ) - else: - result = run( - ["nix-build", "-A", ref.attr_path, "--no-out-link"], - timeout=timeout, - check=False, - ) - return result + return run( + ["nix-build", "-A", ref.attr_path, "--no-out-link"], + timeout=timeout, + check=False, + )