Compare commits

..

11 commits

Author SHA1 Message Date
jade fe7f6ec62b Merge pull request 'Update readme' (#67) from cobaltcause/flake-compat:readme into main
Reviewed-on: #67
2024-11-26 06:42:46 +00:00
Charles Hall e44e6cf654
prefix fetchTarball with builtins. too
For consistency/clarity.
2024-11-25 11:30:47 -08:00
Charles Hall 8c1dda128e
document that flake = false is optional
Some projects like to set `flake = false` for all inputs; this is
good for them to know so they can stay consistent about it.
2024-11-25 11:30:23 -08:00
Charles Hall 6327d063de
don't depend on input that can change
That would break when:

* A flake.lock is created
* The main branch is updated
* The user doesn't have the tarball corresponding to the previous
  version of the main branch in their store

because the hashes won't match.
2024-11-25 11:30:14 -08:00
Charles Hall 1fadfb6600
remove warning about lix being private
Because it isn't anymore.
2024-11-25 11:28:22 -08:00
jade 33a2aba01c Merge pull request 'make flake inputs easily available to classic nix' (#68) from cobaltcause/flake-compat:expose-inputs into main
Reviewed-on: #68
Reviewed-by: jade <jade@noreply.git.lix.systems>
2024-11-25 18:56:35 +00:00
Charles Hall 127c86e1d4
make flake inputs easily available to classic nix
This makes it easier to control the "shape" of the `default.nix`.
2024-11-24 19:06:44 -08:00
jade 5adafc5bfb fix wrong comment 2024-05-02 20:09:04 -07:00
jade 87e36b9f18 un-flakes your hub
fixes #66
2024-05-02 19:56:08 -07:00
jade 1be18e491b Merge pull request 'Check for pure eval mode before calling builtins.storePath' (#65) from 9999years/fix-64 into master
Reviewed-on: #65
2024-04-30 19:53:03 +00:00
Rebecca Turner baa7aa7bd0
Check for pure eval mode before calling builtins.storePath 2024-03-08 16:32:20 -08:00
3 changed files with 18 additions and 25 deletions

View file

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

View file

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