mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
update-scripts/version-info: convert to a script
This will allow us to do impure things if needed.
This commit is contained in:
parent
80934be3e9
commit
a95db128a6
3 changed files with 43 additions and 32 deletions
|
@ -43,7 +43,7 @@ writeShellApplication {
|
||||||
|
|
||||||
versionInfo() {
|
versionInfo() {
|
||||||
nix-build ./update-scripts -A version-info
|
nix-build ./update-scripts -A version-info
|
||||||
install -m 644 -T "$(realpath result)" ./version-info.toml
|
./result
|
||||||
if [ -n "$commit" ]; then
|
if [ -n "$commit" ]; then
|
||||||
git add version-info.toml
|
git add version-info.toml
|
||||||
git commit "$@"
|
git commit "$@"
|
||||||
|
|
|
@ -1,36 +1,20 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
writers,
|
callPackage,
|
||||||
runCommand,
|
writeShellApplication,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (builtins)
|
mainInfo = callPackage ./main.nix { };
|
||||||
all
|
|
||||||
match
|
|
||||||
attrNames
|
|
||||||
;
|
|
||||||
inherit (lib)
|
|
||||||
importJSON
|
|
||||||
;
|
|
||||||
|
|
||||||
lockFile = importJSON ../../flake.lock;
|
|
||||||
nixpkgsLock =
|
|
||||||
# Assert there is only one nixpkgs node
|
|
||||||
assert all (node: match "nixpkgs_[0-9]+" node == null) (attrNames lockFile.nodes);
|
|
||||||
lockFile.nodes.nixpkgs.original;
|
|
||||||
|
|
||||||
info = {
|
|
||||||
inherit (lib.trivial) release;
|
|
||||||
nixpkgs_rev = lib.trivial.revisionWithDefault (throw "nixpkgs revision not available");
|
|
||||||
unstable = lib.strings.hasSuffix "-unstable" nixpkgsLock.ref;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
runCommand "version-info.toml" { } ''
|
writeShellApplication {
|
||||||
(
|
name = "version-info";
|
||||||
echo "# DO NOT MODIFY!"
|
text = ''
|
||||||
echo "# This file was generated by ${
|
(
|
||||||
lib.strings.removePrefix (toString ../.. + "/") (toString ./default.nix)
|
echo "# DO NOT MODIFY!"
|
||||||
}"
|
echo "# This file was generated by ${
|
||||||
cat ${writers.writeTOML "version-info.toml" info}
|
lib.strings.removePrefix (toString ../.. + "/") (toString ./default.nix)
|
||||||
) > $out
|
}"
|
||||||
''
|
cat ${mainInfo}
|
||||||
|
) > version-info.toml
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
27
update-scripts/version-info/main.nix
Normal file
27
update-scripts/version-info/main.nix
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
writers,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (builtins)
|
||||||
|
all
|
||||||
|
match
|
||||||
|
attrNames
|
||||||
|
;
|
||||||
|
inherit (lib)
|
||||||
|
importJSON
|
||||||
|
;
|
||||||
|
|
||||||
|
lockFile = importJSON ../../flake.lock;
|
||||||
|
nixpkgsLock =
|
||||||
|
# Assert there is only one nixpkgs node
|
||||||
|
assert all (node: match "nixpkgs_[0-9]+" node == null) (attrNames lockFile.nodes);
|
||||||
|
lockFile.nodes.nixpkgs.original;
|
||||||
|
|
||||||
|
info = {
|
||||||
|
inherit (lib.trivial) release;
|
||||||
|
nixpkgs_rev = lib.trivial.revisionWithDefault (throw "nixpkgs revision not available");
|
||||||
|
unstable = lib.strings.hasSuffix "-unstable" nixpkgsLock.ref;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
writers.writeTOML "version-info.toml" info
|
Loading…
Add table
Add a link
Reference in a new issue