diff --git a/inputs.nix b/inputs.nix index 1c6c039..1979433 100644 --- a/inputs.nix +++ b/inputs.nix @@ -1,84 +1,29 @@ let self = { - lock ? import lockFile, - lockFile ? ./lock.nix, - pkgs ? throw "inputs called without pkgs", + lock ? import ./lock.nix +, lib ? import "${(self {}).nixpkgs}/lib" }: { inherit lock; - nixos-vscode-server = rec { + nixos-vscode-server = builtins.fetchTarball { + name = "nixos-vscode-server"; url = "https://github.com/nix-community/nixos-vscode-server/archive/${lock.nixos-vscode-server.revision}.tar.gz"; - updateScript = pkgs.den-http-get-updater { - fileLocation = lockFile; - previousHash = lock.nixos-vscode-server.sha256; - previousVersion = lock.nixos-vscode-server.revision; - versionUrl = "https://api.github.com/repos/nix-community/nixos-vscode-server/commits"; - contentParser = "jq -rc '.[0].sha' <<< \"$newVersion\""; - prefetchUrlLocation = { - file = ./inputs.nix; - attrpath = "nixos-vscode-server.url"; - }; - }; - outPath = builtins.fetchTarball { - inherit url; - name = "nixos-vscode-server"; - sha256 = "${lock.nixos-vscode-server.sha256}"; - }; + sha256 = "${lock.nixos-vscode-server.sha256}"; }; - nixpkgs = rec { + nixpkgs = builtins.fetchTarball { + name = "nixpkgs"; url = "https://github.com/NixOS/nixpkgs/archive/${lock.nixpkgs.revision}.tar.gz"; - updateScript = pkgs.den-http-get-updater { - fileLocation = lockFile; - previousHash = lock.nixpkgs.sha256; - previousVersion = lock.nixpkgs.revision; - versionUrl = "https://channels.nixos.org/nixos-24.11/git-revision"; - prefetchUrlLocation = { - file = ./inputs.nix; - attrpath = "nixpkgs.url"; - }; - }; - outPath = builtins.fetchTarball { - inherit url; - name = "nixpkgs"; - sha256 = "${lock.nixpkgs.sha256}"; - }; + sha256 = "${lock.nixpkgs.sha256}"; }; - nixpkgs-unstable = rec { + nixpkgs-unstable = builtins.fetchTarball { + name = "nixpkgs-unstable"; url = "https://github.com/NixOS/nixpkgs/archive/${lock.nixpkgs-unstable.revision}.tar.gz"; - updateScript = pkgs.den-http-get-updater { - fileLocation = lockFile; - previousHash = lock.nixpkgs-unstable.sha256; - previousVersion = lock.nixpkgs-unstable.revision; - versionUrl = "https://channels.nixos.org/nixos-unstable/git-revision"; - prefetchUrlLocation = { - file = ./inputs.nix; - attrpath = "nixpkgs-unstable.url"; - }; - }; - outPath = builtins.fetchTarball { - inherit url; - name = "nixpkgs-unstable"; - sha256 = "${lock.nixpkgs-unstable.sha256}"; - }; + sha256 = "${lock.nixpkgs-unstable.sha256}"; }; - cosmic-modules = rec { + cosmic-modules = builtins.fetchTarball { + name = "cosmic-modules"; url = "https://github.com/lilyinstarlight/nixos-cosmic/archive/${lock.cosmic-modules.revision}.tar.gz"; - updateScript = pkgs.den-http-get-updater { - fileLocation = lockFile; - previousHash = lock.cosmic-modules.sha256; - previousVersion = lock.cosmic-modules.revision; - versionUrl = "https://api.github.com/repos/lilyinstarlight/nixos-cosmic/commits"; - contentParser = "jq -rc '.[0].sha' <<< \"$newVersion\""; - prefetchUrlLocation = { - file = ./inputs.nix; - attrpath = "cosmic-modules.url"; - }; - }; - outPath = builtins.fetchTarball { - inherit url; - name = "cosmic-modules"; - sha256 = "${lock.cosmic-modules.sha256}"; - }; + sha256 = "${lock.cosmic-modules.sha256}"; }; }; in self diff --git a/lock.nix b/lock.nix index 434dd53..7676e50 100644 --- a/lock.nix +++ b/lock.nix @@ -7,18 +7,18 @@ }; nixpkgs = { # https://channels.nixos.org/nixos-24.11/git-revision - revision = "a1185f4064c18a5db37c5c84e5638c78b46e3341"; - sha256 = "0ipjb56fdhfvhgnrw0rvp89g0mplpyhjil29fqdcpmv4ablbadqc"; + revision = "cdd2ef009676ac92b715ff26630164bb88fec4e0"; + sha256 = "0r5c1l5cagxykyjfh1wsn8wk9vhay5dpwp36318hizn4rcrp9dm6"; }; nixpkgs-unstable = { # https://channels.nixos.org/nixos-unstable/git-revision - revision = "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5"; - sha256 = "1sfb9g6fmyfligcsd1rmkamfqvy8kgn3p0sy8ickf6swi1zdbf0b"; + revision = "6607cf789e541e7873d40d3a8f7815ea92204f32"; + sha256 = "0lad6jan49sywk6xzgcivc4h3ln7grhjhb8q8jv2jwhwlgrfrxvh"; }; cosmic-modules = { # https://api.github.com/repos/lilyinstarlight/nixos-cosmic/commits # jsonpath: [1].sha - revision = "fcee247f21d21acb738ac208d6ed86e65c2e7240"; - sha256 = "18xw0innlpswz35cf8n16myh5a24b4kpw0xckwm42c93zd5rm2zh"; + revision = "24785e84d4b3844936caffe2c56994bdef9a9300"; + sha256 = "18qqbhw5kk5j2i741faamipbga590ywxkax19ny2nz3w2zfq64k4"; }; } diff --git a/outputs.nix b/outputs.nix index 76b8b85..adc23e6 100644 --- a/outputs.nix +++ b/outputs.nix @@ -1,6 +1,5 @@ { - inputsPath ? ./inputs.nix, - inputs ? import inputsPath {}, + inputs ? import ./inputs.nix {}, selfPath ? ./. }: @@ -17,7 +16,7 @@ systems = [ forEachSystem = lib.genAttrs systems; self = { - inherit inputs inputsPath lib self; + inherit inputs lib self; outPath = selfPath; modifiedNixpkgs = import ./pkgs/top-level/impure.nix; modifiedNixpkgsPure = import ./pkgs/top-level/default.nix; @@ -72,30 +71,6 @@ self = { builtins.attrValues builtins.listToAttrs ]; - # FIXME: currently impure - # NOTE: to run, you need to evaluate outputs.nix instead of default.nix - # nix-shell outputs.nix -A update - update = let - updateScript = (self.packagesForSystem (builtins.currentSystem)).den-update-script; - in updateScript { - path = ""; - packages = lib.pipe ./update-list.nix [ - import - (x: x self) - lib.attrsToList - (lib.imap1 (i: {name, value}: { - name = builtins.toString i; - value = value // { - # hack to pass isDerivation check in nixpkgs maintainers/scripts/update.nix - # https://github.com/NixOS/nixpkgs/blob/a1185f4064c18a5db37c5c84e5638c78b46e3341/maintainers/scripts/update.nix#L85 - type = "derivation"; - name = name; - }; - })) - builtins.listToAttrs - lib.recurseIntoAttrs - ]; - }; }; in self diff --git a/pkgs/by-name/de/den-http-get-updater/package.nix b/pkgs/by-name/de/den-http-get-updater/package.nix deleted file mode 100644 index d22b0ac..0000000 --- a/pkgs/by-name/de/den-http-get-updater/package.nix +++ /dev/null @@ -1,106 +0,0 @@ -{ - lib, - - curl, - gawk, - jq, - nix, - writeScript, -}: - -{ - # location of file to modify - fileLocation, - previousHash, - previousVersion, - versionUrl, - prefetchUrlLocation ? null, - # change newVersion variable in it, if the contents of the page - # is not plaintext version - # (json for example) - contentParser ? "echo \"$newVersion\"", - - unpack ? true, - name ? if unpack then "source" else null, -}: - -assert builtins.isNull prefetchUrlLocation || lib.isAttrs prefetchUrlLocation; -assert lib.isAttrs prefetchUrlLocation && ( - lib.isString prefetchUrlLocation.file or null || - lib.isPath prefetchUrlLocation.file or null -); -assert lib.isAttrs prefetchUrlLocation && lib.isString prefetchUrlLocation.attrpath or null; - -let - realFileLocation = builtins.toString fileLocation; - mark = builtins.hashString "sha256" previousHash; - - mark' = lib.escapeShellArg mark; - prefetchUrlLocation' = lib.mapAttrs (_: lib.escapeShellArg) prefetchUrlLocation; - realFileLocation' = lib.escapeShellArg realFileLocation; - versionUrl' = lib.escapeShellArg versionUrl; - - mark'' = lib.escapeShellArg (lib.escapeRegex mark); - previousVersion'' = lib.escapeShellArg (lib.escapeRegex previousVersion); - - nixUnpack = lib.optionalString unpack "--unpack"; - nixName = lib.optionalString (!builtins.isNull name) "--name \"${lib.escapeShellArg name}\""; - - path = lib.makeBinPath [ - curl - gawk - jq - nix - ]; -in - -writeScript "den-http-get-updater" ('' - PATH="${lib.escapeShellArg path}" - - newVersion=$(curl -L "${versionUrl'}") - if [[ "$?" != 0 ]]; then - echo "error: fetching new version failed" 1>&2 - exit 1 - fi - newVersion=$(${contentParser}) - awk -i inplace "{ - sub(/${previousVersion''}/, \"$newVersion\") - # invalidate hash - sub(/${previousHash}/, \"${mark'}\") - }1" "${realFileLocation'}" -'' + lib.optionalString (!builtins.isNull prefetchUrlLocation) '' - nixUrlsResult=$(nix-instantiate --eval --json \ - "${prefetchUrlLocation'.file}" \ - -A "${prefetchUrlLocation'.attrpath}" - ) - - urlsType=$(jq -rc 'type' <<< "$nixUrlsResult") - if [ "$urlsType" = "array" ]; then - readarray -t prefetchUrls < <( - jq -rc '.[]' <<< "$nixUrlsResult" - ) - elif [ "$urlsType" = "string" ]; then - readarray -t prefetchUrls < <( - jq -rc '.' <<< "$nixUrlsResult" - ) - fi - - prefetchSucceeded=1 - for url in "''${prefetchUrls[@]}"; do - echo "trying prefetch '$url'..."; - expectedHash=$(nix-prefetch-url "$url" ${nixUnpack} ${nixName}) - if [[ -n $expectedHash ]]; then - echo "prefetch succeeded!" - echo "hash: $expectedHash" - awk -i inplace "{ - sub(/${mark''}/, \"$expectedHash\") - }1" "${realFileLocation'}" - prefetchSucceeded= - break - fi - done - if [[ -n "$prefetchSucceeded" ]]; then - echo "warning: prefetch failed" 1>&2 - exit 1 - fi -'') diff --git a/pkgs/by-name/de/den-update-script/package.nix b/pkgs/by-name/de/den-update-script/package.nix deleted file mode 100644 index 662e3ce..0000000 --- a/pkgs/by-name/de/den-update-script/package.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ - lib, - path, - - overlayAttrname ? "den-outputs", -}: - -assert lib.assertMsg (!lib.hasInfix "." overlayAttrname) (lib.pipe '' - overlayAttrname must not contain a dot (.), - because dot is used to reference package in a package set - inside nix-update-script. -'' [ - lib.lines - (lib.concatStringsSep " ") -]); - -let - updateScript = import (path + /maintainers/scripts/update.nix); - functionArgs = lib.functionArgs updateScript; - nameInFunctionArgs = name: lib.elem name (lib.attrNames functionArgs); -in -{ - __functionArgs = functionArgs // { packages = false; }; - __functor = _: args: let - # args.outputs should be an attrset of packages to update - overlay = _: _: { - "${overlayAttrname}" = args.packages; - }; - in updateScript (lib.filterAttrs (name: _: nameInFunctionArgs name) args // { - include-overlays = - if !args ? updateScript then [ overlay ] - else if lib.isList args.updateScript then [ overlay ] ++ args.updateScript - else args.updateScript; - } // lib.optionalAttrs (args ? package) { - package = "${overlayAttrname}.${args.package}"; - } // lib.optionalAttrs (args ? path) { - path = if lib.stringLength args.path == 0 then overlayAttrname else "${overlayAttrname}.${args.path}"; - }); -} diff --git a/update-list.nix b/update-list.nix deleted file mode 100644 index 9ce74c3..0000000 --- a/update-list.nix +++ /dev/null @@ -1,13 +0,0 @@ -self: - -# MARK: inputs -( let - inputsWithPackages = import self.inputsPath { - pkgs = self.packagesForSystem builtins.currentSystem; - }; -in { - "inputs/nixpkgs" = inputsWithPackages.nixpkgs; - "inputs/nixpkgs-unstable" = inputsWithPackages.nixpkgs-unstable; - "inputs/cosmic-modules" = inputsWithPackages.cosmic-modules; - "inputs/nixos-vscode-server" = inputsWithPackages.nixos-vscode-server; -})