Compare commits
6 commits
567358418b
...
72d18c49fe
Author | SHA1 | Date | |
---|---|---|---|
72d18c49fe | |||
59d6ba8f97 | |||
476cf36b57 | |||
ec12c3eee4 | |||
7ec22b6e52 | |||
3fb3b7771f |
6 changed files with 260 additions and 22 deletions
83
inputs.nix
83
inputs.nix
|
@ -1,29 +1,84 @@
|
|||
let self = {
|
||||
lock ? import ./lock.nix
|
||||
, lib ? import "${(self {}).nixpkgs}/lib"
|
||||
lock ? import lockFile,
|
||||
lockFile ? ./lock.nix,
|
||||
pkgs ? throw "inputs called without pkgs",
|
||||
}:
|
||||
|
||||
{
|
||||
inherit lock;
|
||||
nixos-vscode-server = builtins.fetchTarball {
|
||||
name = "nixos-vscode-server";
|
||||
nixos-vscode-server = rec {
|
||||
url = "https://github.com/nix-community/nixos-vscode-server/archive/${lock.nixos-vscode-server.revision}.tar.gz";
|
||||
sha256 = "${lock.nixos-vscode-server.sha256}";
|
||||
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}";
|
||||
};
|
||||
};
|
||||
nixpkgs = builtins.fetchTarball {
|
||||
name = "nixpkgs";
|
||||
nixpkgs = rec {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${lock.nixpkgs.revision}.tar.gz";
|
||||
sha256 = "${lock.nixpkgs.sha256}";
|
||||
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}";
|
||||
};
|
||||
};
|
||||
nixpkgs-unstable = builtins.fetchTarball {
|
||||
name = "nixpkgs-unstable";
|
||||
nixpkgs-unstable = rec {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${lock.nixpkgs-unstable.revision}.tar.gz";
|
||||
sha256 = "${lock.nixpkgs-unstable.sha256}";
|
||||
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}";
|
||||
};
|
||||
};
|
||||
cosmic-modules = builtins.fetchTarball {
|
||||
name = "cosmic-modules";
|
||||
cosmic-modules = rec {
|
||||
url = "https://github.com/lilyinstarlight/nixos-cosmic/archive/${lock.cosmic-modules.revision}.tar.gz";
|
||||
sha256 = "${lock.cosmic-modules.sha256}";
|
||||
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}";
|
||||
};
|
||||
};
|
||||
};
|
||||
in self
|
||||
|
|
12
lock.nix
12
lock.nix
|
@ -7,18 +7,18 @@
|
|||
};
|
||||
nixpkgs = {
|
||||
# https://channels.nixos.org/nixos-24.11/git-revision
|
||||
revision = "cdd2ef009676ac92b715ff26630164bb88fec4e0";
|
||||
sha256 = "0r5c1l5cagxykyjfh1wsn8wk9vhay5dpwp36318hizn4rcrp9dm6";
|
||||
revision = "a1185f4064c18a5db37c5c84e5638c78b46e3341";
|
||||
sha256 = "0ipjb56fdhfvhgnrw0rvp89g0mplpyhjil29fqdcpmv4ablbadqc";
|
||||
};
|
||||
nixpkgs-unstable = {
|
||||
# https://channels.nixos.org/nixos-unstable/git-revision
|
||||
revision = "6607cf789e541e7873d40d3a8f7815ea92204f32";
|
||||
sha256 = "0lad6jan49sywk6xzgcivc4h3ln7grhjhb8q8jv2jwhwlgrfrxvh";
|
||||
revision = "c80f6a7e10b39afcc1894e02ef785b1ad0b0d7e5";
|
||||
sha256 = "1sfb9g6fmyfligcsd1rmkamfqvy8kgn3p0sy8ickf6swi1zdbf0b";
|
||||
};
|
||||
cosmic-modules = {
|
||||
# https://api.github.com/repos/lilyinstarlight/nixos-cosmic/commits
|
||||
# jsonpath: [1].sha
|
||||
revision = "24785e84d4b3844936caffe2c56994bdef9a9300";
|
||||
sha256 = "18qqbhw5kk5j2i741faamipbga590ywxkax19ny2nz3w2zfq64k4";
|
||||
revision = "fcee247f21d21acb738ac208d6ed86e65c2e7240";
|
||||
sha256 = "18xw0innlpswz35cf8n16myh5a24b4kpw0xckwm42c93zd5rm2zh";
|
||||
};
|
||||
}
|
||||
|
|
29
outputs.nix
29
outputs.nix
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
inputs ? import ./inputs.nix {},
|
||||
inputsPath ? ./inputs.nix,
|
||||
inputs ? import inputsPath {},
|
||||
selfPath ? ./.
|
||||
}:
|
||||
|
||||
|
@ -16,7 +17,7 @@ systems = [
|
|||
forEachSystem = lib.genAttrs systems;
|
||||
|
||||
self = {
|
||||
inherit inputs lib self;
|
||||
inherit inputs inputsPath lib self;
|
||||
outPath = selfPath;
|
||||
modifiedNixpkgs = import ./pkgs/top-level/impure.nix;
|
||||
modifiedNixpkgsPure = import ./pkgs/top-level/default.nix;
|
||||
|
@ -71,6 +72,30 @@ 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
|
||||
|
|
106
pkgs/by-name/de/den-http-get-updater/package.nix
Normal file
106
pkgs/by-name/de/den-http-get-updater/package.nix
Normal file
|
@ -0,0 +1,106 @@
|
|||
{
|
||||
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
|
||||
'')
|
39
pkgs/by-name/de/den-update-script/package.nix
Normal file
39
pkgs/by-name/de/den-update-script/package.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
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}";
|
||||
});
|
||||
}
|
13
update-list.nix
Normal file
13
update-list.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
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;
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue