Compare commits

...

27 commits

Author SHA1 Message Date
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
Eelco Dolstra 0f9255e01c Force root sources like "./." into the Nix store 2023-10-04 15:37:54 +02:00
Eelco Dolstra 5a16547d46 Prevent double copying and work around an apparent Nix bug
Fixes #60.
2023-10-04 12:49:46 +02:00
Eelco Dolstra 4f910c9827 Doh 2023-10-02 19:19:56 +02:00
Eelco Dolstra 7ae5ae625a Drop "flake = false" and suggest flakehub 2023-10-02 19:16:54 +02:00
Eelco Dolstra e1262c7073
Merge pull request #59 from hercules-ci/port-nix-7796-flake-outPath
nix#7796: Ensure that `self.outPath == ./.`
2023-10-02 19:10:16 +02:00
Robert Hensing bc5e257a8d nix#7796: Ensure that self.outPath == ./.
Ported from https://github.com/NixOS/nix/pull/7796
First released in Nix 2.14
2023-10-02 18:57:55 +02:00
Eelco Dolstra 2bf43d60c7 Change from rolling to tagged releases 2023-10-02 16:09:08 +02:00
Eelco Dolstra 6256b599c8 Add description 2023-10-02 14:48:41 +02:00
Eelco Dolstra c30381e188 Add flake.nix 2023-10-02 14:43:40 +02:00
Eelco Dolstra e654cc30bf
Merge pull request #56 from Alper-Celik/master
add support for sourcehut
2023-10-02 14:15:41 +02:00
Eelco Dolstra 5717e26155
Merge pull request #57 from lucperkins/flakehub-publish
Add FlakeHub publish Action
2023-10-02 14:15:23 +02:00
Luc Perkins 92556b8539
Add FlakeHub publish Action 2023-09-18 14:15:22 +03:00
Alper Çelik bcb80df051
add support for sourcehut 2023-04-26 10:33:29 +03:00
Eelco Dolstra 35bb57c0c8
Merge pull request #50 from hercules-ci/nix-7207-_type-is-flake
Apply nix#7207 `_type = "flake";`
2023-01-17 12:47:33 +01:00
Robert Hensing 43bfa87aa2 Apply nix#7207 _type = "flake";
https://github.com/NixOS/nix/pull/7207 adds this attribute in order
to help identify flake outputs for the purpose of type checking.
2023-01-16 19:59:47 +01:00
Eelco Dolstra 009399224d
Merge pull request #47 from blaggacao/master
fix: top level functors break legacy nix commands
2022-11-17 11:41:32 +01:00
David Arnold 6f56392cc4
fix: top level functors break legacy nix commands
see: https://github.com/divnix/std/issues/186
2022-11-14 20:28:19 -05:00
Eelco Dolstra b4a34015c6
Merge pull request #40 from SuperSandro2000/patch-1
Quote url literal
2022-04-19 15:22:48 +02:00
Sandro 246e885130
Quote url literal 2022-04-19 13:59:50 +02:00
Eelco Dolstra 64a525ee38
Merge pull request #37 from Artturin/addsupportfornewshcmea
add support for new style of defaults
2022-03-25 10:10:09 +01:00
Eelco Dolstra 913e1270ff
Merge pull request #36 from charlesbaynham/master
Support submodules fetches for git imports
2022-03-25 10:09:12 +01:00
Artturin aee797a673 add support for new style of defaults 2022-03-25 04:47:29 +02:00
Charles Baynham 3b935d922d
Pass along submodules flag to fetchGit 2022-03-19 23:30:58 +00:00
3 changed files with 73 additions and 12 deletions

View file

@ -2,13 +2,25 @@
## Usage ## Usage
> [!WARNING]
> During the Lix private beta period during which Forgejo is private, this
> requires configuring netrc in Lix for the tarball download to work.
>
> Your netrc should look something like so:
> ```
> machine git.lix.systems login YOUR-USERNAME password SOME-PERSONAL-ACCESS-TOKEN-REPO-READ
> ```
>
> We are terribly sorry for the UX for this being very bad
> ([issue](https://git.lix.systems/lix-project/lix/issues/254)).
To use, add the following to your `flake.nix`: To use, add the following to your `flake.nix`:
<!-- FIXME: this can use the standard non-api archive url when we are
un-privated -->
```nix ```nix
inputs.flake-compat = { inputs.flake-compat.url = "https://git.lix.systems/api/v1/repos/lix-project/flake-compat/archive/main.tar.gz";
url = github:edolstra/flake-compat;
flake = false;
};
``` ```
Afterwards, create a `default.nix` file containing the following: Afterwards, create a `default.nix` file containing the following:
@ -18,7 +30,7 @@ Afterwards, create a `default.nix` file containing the following:
( (
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball { fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; url = lock.nodes.flake-compat.locked.url;
sha256 = lock.nodes.flake-compat.locked.narHash; sha256 = lock.nodes.flake-compat.locked.narHash;
} }
) )

View file

@ -33,6 +33,7 @@ let
({ url = info.url; } ({ url = info.url; }
// (if info ? rev then { inherit (info) rev; } else {}) // (if info ? rev then { inherit (info) rev; } else {})
// (if info ? ref then { inherit (info) ref; } else {}) // (if info ? ref then { inherit (info) ref; } else {})
// (if info ? submodules then { inherit (info) submodules; } else {})
); );
lastModified = info.lastModified; lastModified = info.lastModified;
lastModifiedDate = formatSecondsSinceEpoch info.lastModified; lastModifiedDate = formatSecondsSinceEpoch info.lastModified;
@ -62,8 +63,17 @@ let
); );
shortRev = builtins.substring 0 7 info.rev; shortRev = builtins.substring 0 7 info.rev;
} }
else if info.type == "sourcehut" then
{ inherit (info) rev narHash lastModified;
outPath =
fetchTarball
({ url = "https://${info.host or "git.sr.ht"}/${info.owner}/${info.repo}/archive/${info.rev}.tar.gz"; }
// (if info ? narHash then { sha256 = info.narHash; } else {})
);
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:
@ -94,7 +104,22 @@ let
then then
let res = builtins.fetchGit src; let res = builtins.fetchGit src;
in if res.rev == "0000000000000000000000000000000000000000" then removeAttrs res ["rev" "shortRev"] else res in if res.rev == "0000000000000000000000000000000000000000" then removeAttrs res ["rev" "shortRev"] else res
else { outPath = src; }; else {
outPath =
# Massage `src` into a store path.
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
else
"${src}"
else
src;
};
# NB git worktrees have a file for .git, so we don't check the type of .git # NB git worktrees have a file for .git, so we don't check the type of .git
isGit = builtins.pathExists (src + "/.git"); isGit = builtins.pathExists (src + "/.git");
isShallow = builtins.pathExists (src + "/.git/shallow"); isShallow = builtins.pathExists (src + "/.git/shallow");
@ -139,7 +164,9 @@ let
subdir = if key == lockFile.root then "" else node.locked.dir or ""; subdir = if key == lockFile.root then "" else node.locked.dir or "";
flake = import (sourceInfo + (if subdir != "" then "/" else "") + subdir + "/flake.nix"); outPath = sourceInfo + ((if subdir == "" then "" else "/") + subdir);
flake = import (outPath + "/flake.nix");
inputs = builtins.mapAttrs inputs = builtins.mapAttrs
(inputName: inputSpec: allNodes.${resolveInput inputSpec}) (inputName: inputSpec: allNodes.${resolveInput inputSpec})
@ -166,7 +193,21 @@ let
outputs = flake.outputs (inputs // { self = result; }); outputs = flake.outputs (inputs // { self = result; });
result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; }; result =
outputs
# We add the sourceInfo attribute for its metadata, as they are
# relevant metadata for the flake. However, the outPath of the
# sourceInfo does not necessarily match the outPath of the flake,
# as the flake may be in a subdirectory of a source.
# This is shadowed in the next //
// sourceInfo
// {
# This shadows the sourceInfo.outPath
inherit outPath;
inherit inputs; inherit outputs; inherit sourceInfo; _type = "flake";
};
in in
if node.flake or true then if node.flake or true then
assert builtins.isFunction flake.outputs; assert builtins.isFunction flake.outputs;
@ -188,10 +229,12 @@ let
in in
rec { rec {
defaultNix = defaultNix =
result (builtins.removeAttrs result ["__functor"])
// (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {}); // (if result ? defaultPackage.${system} then { default = result.defaultPackage.${system}; } else {})
// (if result ? packages.${system}.default then { default = result.packages.${system}.default; } else {});
shellNix = shellNix =
defaultNix defaultNix
// (if result ? devShell.${system} then { default = result.devShell.${system}; } else {}); // (if result ? devShell.${system} then { default = result.devShell.${system}; } else {})
// (if result ? devShells.${system}.default then { default = result.devShells.${system}.default; } else {});
} }

6
flake.nix Normal file
View file

@ -0,0 +1,6 @@
{
description = "Allow flakes to be used with Nix < 2.4";
outputs = { self }: {
};
}