init
This commit is contained in:
commit
996bcd0fa1
6 changed files with 329 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
flendor.json
|
||||
vendor/
|
20
README.md
Normal file
20
README.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# flendor
|
||||
|
||||
Super simple flake input vendoring.
|
||||
|
||||
Example `flendor.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"vendor": "vendor",
|
||||
"flakes": {
|
||||
"musicomp": "git+https://forgejo.helveticanonstandard.net/helvetica/musicomp.git",
|
||||
"hxwrap": "git+https://forgejo.helveticanonstandard.net/helvetica/hxwrap.git",
|
||||
"myphps": "git+https://forgejo.helveticanonstandard.net/helvetica/myphps.git",
|
||||
"forgesync": "git+https://forgejo.helveticanonstandard.net/helvetica/forgesync.git",
|
||||
"nini": "git+https://forgejo.helveticanonstandard.net/helvetica/nini.git",
|
||||
"xenumenu": "git+https://forgejo.helveticanonstandard.net/helvetica/xenumenu.git",
|
||||
"mympv": "git+https://forgejo.helveticanonstandard.net/helvetica/mympv.git"
|
||||
}
|
||||
}
|
||||
```
|
142
flake.lock
generated
Normal file
142
flake.lock
generated
Normal file
|
@ -0,0 +1,142 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1753121425,
|
||||
"narHash": "sha256-TVcTNvOeWWk1DXljFxVRp+E0tzG1LhrVjOGGoMHuXio=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "644e0fc48951a860279da645ba77fe4a6e814c5e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1750779888,
|
||||
"narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1753250450,
|
||||
"narHash": "sha256-i+CQV2rPmP8wHxj0aq4siYyohHwVlsh40kV89f3nw1s=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fc02ee70efb805d3b2865908a13ddd4474557ecf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1751159883,
|
||||
"narHash": "sha256-urW/Ylk9FIfvXfliA1ywh75yszAbiTEVgpPeinFyVZo=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "14a40a1d7fb9afa4739275ac642ed7301a9ba1ab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"hooks": "hooks",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"treefmt": "treefmt"
|
||||
}
|
||||
},
|
||||
"treefmt": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1753439394,
|
||||
"narHash": "sha256-Bv9h1AJegLI8uAhiJ1sZ4XAndYxhgf38tMgCQwiEpmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "2673921c03d6e75fdf4aa93e025772608d1482cf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
62
flake.nix
Normal file
62
flake.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
description = "flendor";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
hooks = {
|
||||
url = "github:cachix/git-hooks.nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
treefmt = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-parts,
|
||||
hooks,
|
||||
treefmt,
|
||||
}@inputs:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [
|
||||
hooks.flakeModule
|
||||
treefmt.flakeModule
|
||||
];
|
||||
|
||||
systems = nixpkgs.lib.systems.flakeExposed;
|
||||
|
||||
perSystem =
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
treefmt = {
|
||||
projectRootFile = "flake.nix";
|
||||
|
||||
programs.nixfmt = {
|
||||
enable = true;
|
||||
package = pkgs.nixfmt-rfc-style;
|
||||
};
|
||||
};
|
||||
|
||||
pre-commit.settings.hooks = {
|
||||
treefmt.enable = true;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShellNoCC {
|
||||
shellHook = ''
|
||||
${config.pre-commit.installationScript}
|
||||
'';
|
||||
};
|
||||
|
||||
packages.default = pkgs.callPackage ./package.nix { };
|
||||
};
|
||||
};
|
||||
}
|
90
flendor
Executable file
90
flendor
Executable file
|
@ -0,0 +1,90 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
progname=$0
|
||||
|
||||
warn() {
|
||||
local line
|
||||
for line in "$@"; do
|
||||
echo "$progname: $line" 1>&2
|
||||
done
|
||||
}
|
||||
|
||||
error() {
|
||||
warn "$@"
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
args=$(
|
||||
getopt \
|
||||
--options t:rv \
|
||||
--longoptions vendor:,refresh,verbose \
|
||||
--name "$progname" \
|
||||
-- "$@"
|
||||
)
|
||||
|
||||
eval set -- "$args"
|
||||
|
||||
nixflags=()
|
||||
rmflags=()
|
||||
mkdirflags=()
|
||||
cpflags=()
|
||||
prefetchflags=()
|
||||
verbose=false
|
||||
while true; do
|
||||
case $1 in
|
||||
-d | --vendor)
|
||||
vendor=$2
|
||||
shift 2
|
||||
;;
|
||||
-r | --refresh)
|
||||
prefetchflags+=(--refresh)
|
||||
shift
|
||||
;;
|
||||
-v | --verbose)
|
||||
nixflags+=(--verbose)
|
||||
rmflags+=(--verbose)
|
||||
mkdirflags+=(--verbose)
|
||||
cpflags+=(--verbose)
|
||||
verbose=true
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if (($# > 0)); then
|
||||
error 'too many arguments'
|
||||
fi
|
||||
|
||||
json=$(< flendor.json)
|
||||
|
||||
if [[ ! -v vendor ]]; then
|
||||
vendor=$(jq --exit-status --raw-output '.vendor' <<<"$json")
|
||||
fi
|
||||
|
||||
while IFS= read -r k; do
|
||||
name=$(jq --null-input --argjson k "$k" --raw-output '$k')
|
||||
flake=$(jq --argjson k "$k" --raw-output '.flakes.[$k]' <<<"$json")
|
||||
|
||||
dest="$vendor/$name"
|
||||
|
||||
if [[ $verbose == true ]]; then
|
||||
warn "copying flake $flake to $dest"
|
||||
fi
|
||||
|
||||
rm --recursive --force "${rmflags[@]}" -- "$dest"
|
||||
|
||||
src=$(nix flake prefetch --json "${prefetchflags[@]}" -- "$flake" | jq --exit-status --raw-output '.storePath')
|
||||
|
||||
mkdir --parents "${mkdirflags[@]}" -- "$(dirname -- "$dest")"
|
||||
|
||||
cp --recursive --no-preserve all "${cpflags[@]}" -- "$src/." "$dest"
|
||||
done < <(jq '.flakes | keys[]' <<<"$json")
|
13
package.nix
Normal file
13
package.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
writeShellApplication,
|
||||
jq,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "jq";
|
||||
|
||||
runtimeInputs = [
|
||||
jq
|
||||
];
|
||||
|
||||
text = builtins.readFile ./flendor;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue