Compare commits

..

1 commit

Author SHA1 Message Date
Enis Bayramoğlu 6ef9397736
Allow overriding the tarball fetcher 2023-11-07 20:12:58 +01:00
3 changed files with 25 additions and 18 deletions

18
.github/workflows/flakehub-publish.yml vendored Normal file
View file

@ -0,0 +1,18 @@
name: "Publish to FlakeHub"
on:
push:
tags:
- "v*.*.*"
jobs:
flakehub-publish:
runs-on: "ubuntu-latest"
permissions:
id-token: "write"
contents: "read"
steps:
- uses: "actions/checkout@v3"
- uses: "DeterminateSystems/nix-installer-action@main"
- uses: "DeterminateSystems/flakehub-push@main"
with:
name: "edolstra/flake-compat"
visibility: "public"

View file

@ -5,11 +5,7 @@
To use, add the following to your `flake.nix`:
```nix
inputs.flake-compat = {
url = "git+https://git.lix.systems/lix-project/flake-compat";
# Optional:
flake = false;
};
inputs.flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
```
Afterwards, create a `default.nix` file containing the following:
@ -17,13 +13,10 @@ Afterwards, create a `default.nix` file containing the following:
```nix
(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
inherit (lock.nodes.flake-compat.locked) narHash rev url;
in
builtins.fetchTarball {
url = "${url}/archive/${rev}.tar.gz";
sha256 = narHash;
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }

View file

@ -5,7 +5,7 @@
# containing 'defaultNix' (to be used in 'default.nix'), 'shellNix'
# (to be used in 'shell.nix').
{ src, system ? builtins.currentSystem or "unknown-system" }:
{ src, fetchTarball ? builtins.fetchTarball, system ? builtins.currentSystem or "unknown-system" }:
let
@ -73,7 +73,7 @@ let
shortRev = builtins.substring 0 7 info.rev;
}
else
# FIXME: add Mercurial inputs.
# FIXME: add Mercurial, tarball inputs.
throw "flake input has unsupported input type '${info.type}'";
callFlake4 = flakeSrc: locks:
@ -110,8 +110,6 @@ let
if builtins.isPath src
then
if dirOf (toString src) == builtins.storeDir
# `builtins.storePath` is not available in pure-eval mode.
&& builtins ? currentSystem
then
# If it's already a store path, don't copy it again.
builtins.storePath src
@ -228,8 +226,6 @@ let
in
rec {
inputs = result.inputs // { self = result; };
defaultNix =
(builtins.removeAttrs result ["__functor"])
// (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {})