Commit Graph

283 Commits

Author SHA1 Message Date
Ivan Petkov
c2acd4b443
Minor cleanup 2022-06-02 19:49:44 -07:00
adisbladis
69c96f9d9e checks: Add a check that hits default.nix in the root
This is testing stable Nix (i.e. non-flakes).
2022-06-03 02:01:02 +08:00
adisbladis
c097eedd6b checks: Regenerate expected output for failing checks
Having changed the way of writing TOML there are some differences in output ordering.
2022-06-03 02:01:02 +08:00
adisbladis
26daa5a397 Add a meaningful default.nix
That can be used from classic Nix (i.e. non-Flakes) like this:
``` nix
{ lib ? pkgs.lib
, pkgs ? import <nixpkgs> { }
}:

let
  craneLib = import ../crane { inherit pkgs; };

  src = lib.cleanSource ./.;

  cargoArtifacts = craneLib.buildDepsOnly {
    inherit src;
  };

in craneLib.buildPackage {
  inherit cargoArtifacts src;
}
```
2022-06-03 02:01:02 +08:00
adisbladis
5d5803ff75 flake: Remove nix-std dependency
The only thing used from this library was the toTOML which is now
handled directly in the TOML writer.
2022-06-03 02:01:02 +08:00
adisbladis
a1e56fba69 Stop passing around fromTOML
It's a builtin that we can just use directly.
2022-06-03 02:01:02 +08:00
adisbladis
2491382d63 Remove internal dependency on toTOML 2022-06-03 02:01:02 +08:00
adisbladis
8b42ac1096 default.nix: Move to shell.nix
In it's current form the default.nix file is not useful, but a
shell.nix for classic Nix development might be.
2022-06-02 14:23:13 +08:00
Ivan Petkov
d64285699a
Merge pull request #38 from ipetkov/nix-bump
ci: bump stable Nix to use 22.05 release
2022-06-01 17:32:52 -07:00
Ivan Petkov
4035bf80da
flake.lock: Update
Flake lock file updates:

• Updated input 'flake-utils':
    'github:numtide/flake-utils/a4b154ebbdc88c8498a5c7b01589addc9e9cb678' (2022-04-11)
  → 'github:numtide/flake-utils/1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1' (2022-05-30)
• Updated input 'nix-std':
    'github:chessai/nix-std/8b8d32582e298da2c15b4c13ca48ba7994ef96df' (2022-03-18)
  → 'github:chessai/nix-std/082f38023b68f93cd3a6e3a8ddda54d3f5487c52' (2022-05-15)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/d146577610c17d7674a2d3e285fc637c520ad344' (2022-04-27)
  → 'github:NixOS/nixpkgs/5643714dea562f0161529ab23058562afeff46d0' (2022-05-31)
2022-06-01 17:17:48 -07:00
Ivan Petkov
e78d9b8370
checks: enable tarpaulin checks only on x86_64-linux 2022-06-01 17:17:02 -07:00
Ivan Petkov
57825c24da
Update all flake attributes to follow the new .default format 2022-06-01 17:09:29 -07:00
Ivan Petkov
4bd60ab128
Drop compatibility for Nix versions below 2.8.1 2022-06-01 17:05:52 -07:00
Ivan Petkov
30eadf3b3f
ci: bump nix stable version to 2.8.1 2022-06-01 17:03:31 -07:00
Ivan Petkov
4cce5fe54f
Tag v0.4.1 2022-05-29 16:10:28 -07:00
Ivan Petkov
cec8c8674c
Merge pull request #32 from ipetkov/fix-dummy-invalidation
mkDummySrc: fix cache invalidation if src is flake root
2022-05-29 16:08:44 -07:00
Ivan Petkov
aee882293f
Update CHANGELOG 2022-05-29 16:03:35 -07:00
Ivan Petkov
e0fbad205b
Add extra tests for mkDummySrc inputs 2022-05-29 15:43:58 -07:00
Ivan Petkov
8261aaeb8f quick-start: update to conditionally enable cargo-tarpaulin
* Seems like cargo-tarpaulin only officially supports x86_64 systems,
  and more recent versions are marked as broken on other systems in
  nixpkgs
2022-05-21 20:32:10 -07:00
Ivan Petkov
4f2b1c43c9
mkDummySrc: fix cache invalidation if src is flake root 2022-05-16 20:10:38 -07:00
Ivan Petkov
a233d51034
Also update README example 2 2022-05-12 16:16:21 -07:00
Ivan Petkov
8f2570a7cc
Improve README example to show how to share args between derivations
Fixes #25
2022-05-12 16:07:05 -07:00
Ivan Petkov
a3a6df2181
Merge pull request #27 from TristanCacqueray/cross-musl-path 2022-05-11 15:52:40 -07:00
Tristan Cacqueray
092dac897e flake: fix cross-musl path 2022-05-11 21:37:47 +00:00
Ivan Petkov
ca0bc628fc
Update changelog 2022-05-10 17:28:31 -07:00
Ivan Petkov
c8b8597ecb
Merge pull request #26 from firestack/fix/relative-paths
fix(nix-relative-paths): quote relative paths to allow for external sources
2022-05-10 17:21:29 -07:00
Kayla Firestack
e908c1afea fix(nix-relative-paths): quote relative paths to allow for external sources
when trying to use crane with a non local src (eg, not `./.`) we get the error
```
$ nix flake show
<...>
error: access to absolute path '/Cargo.toml' is forbidden in pure eval mode (use '--impure' to override)
(use '--show-trace' to show detailed location information)
```

To fix this, we quote the relative paths so to properly append them to the base path.

https://nixos.wiki/wiki/Nix_Expression_Language#Coercing_a_relative_path_with_interpolated_variables_to_an_absolute_path_.28for_imports.29

## Reproduction flake
```
{
  description = "Build a cargo project without extra checks";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    crane = {
      url = "github:ipetkov/crane";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    external-crate-source = {
      url = "github:ray-kast/empress";
      flake = false;
    };

    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, crane, flake-utils, external-crate-source, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        test-crate = crane.lib.${system}.buildPackage {
          src = external-crate-source.outPath;
        };
      in
      {
        packages.default = test-crate;
      });
}
```
2022-05-10 10:00:00 -04:00
Ivan Petkov
f7fa3b6d70
Merge pull request #23 from ipetkov/buildDepsOnly-all-targets
buildDepsOnly: add `--all-targets` to default cargoCheckCommand
2022-05-08 20:19:22 -07:00
Ivan Petkov
b47fafa717
buildDepsOnly: add --all-targets to default cargoCheckCommand
This allows caching all artifacts (including from dev-dependencies) such
that tools like clippy don't have to generate them every time they run.
2022-05-08 19:46:58 -07:00
Ivan Petkov
f98c3c7ca7
Merge pull request #22 from ipetkov/dependabot/github_actions/cachix/install-nix-action-17
chore(deps): bump cachix/install-nix-action from 16 to 17
2022-05-01 10:36:15 -07:00
dependabot[bot]
4bd4c72e16
chore(deps): bump cachix/install-nix-action from 16 to 17
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 16 to 17.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v16...v17)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-01 17:00:13 +00:00
Ivan Petkov
b63fe4fd6b
cargo: bump all deps 2022-04-27 20:15:27 -07:00
Ivan Petkov
766c87f404
flake: rename utils input to flake-utils for consistency 2022-04-27 19:59:59 -07:00
Ivan Petkov
83e920dd30
flake.lock: Update
Flake lock file updates:

• Updated input 'flake-compat':
    'github:edolstra/flake-compat/b7547d3eed6f32d06102ead8991ec52ab0a4f1a7' (2022-01-03)
  → 'github:edolstra/flake-compat/b4a34015c698c7793d592d66adbab377907a2be8' (2022-04-19)
• Updated input 'nix-std':
    'github:chessai/nix-std/9ef1cf73948bfad05d370165c7f3011b82c4d679' (2021-06-25)
  → 'github:chessai/nix-std/8b8d32582e298da2c15b4c13ca48ba7994ef96df' (2022-03-18)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/19574af0af3ffaf7c9e359744ed32556f34536bd' (2022-02-16)
  → 'github:NixOS/nixpkgs/d146577610c17d7674a2d3e285fc637c520ad344' (2022-04-27)
• Updated input 'utils':
    'github:numtide/flake-utils/3cecb5b042f7f209c56ffd8371b2711a290ec797' (2022-02-07)
  → 'github:numtide/flake-utils/a4b154ebbdc88c8498a5c7b01589addc9e9cb678' (2022-04-11)
2022-04-27 19:59:32 -07:00
Ivan Petkov
e45196b9f4
Update examples to use {app,package}.default pattern 2022-04-27 19:23:30 -07:00
Ivan Petkov
d3efda535f
Remove superfluous follows declaration for flake-utils 2022-04-27 18:10:22 -07:00
Ivan Petkov
72f078886f
ci: explicitly run default app 2022-04-27 19:38:46 -07:00
Ivan Petkov
f4ceddda25
ci: run on PR updates as well as ci-* branches 2022-04-27 17:17:03 -07:00
Ivan Petkov
39305b3828
Merge pull request #17 from ipetkov/dependabot/github_actions/actions/checkout-3 2022-03-01 15:07:04 -08:00
dependabot[bot]
2e7cbc1a00
chore(deps): bump actions/checkout from 2.4.0 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2.4.0...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-01 22:18:32 +00:00
Ivan Petkov
8629d56b24
Update changelog 2022-02-24 17:58:59 -08:00
Ivan Petkov
a185f3753a
Update cross compile example
* Sometimes we also need to set the HOST_CC environment variable to
  allow cross compiling crates which also need to build a program to run
  on the build platform itself
2022-02-24 17:49:22 -08:00
Ivan Petkov
48b6c6243c
Merge pull request #16 from ipetkov/groupBy-compat
Add compatibility fallback for builtins.groupBy
2022-02-20 22:42:05 +00:00
Ivan Petkov
5e78d64771
ci: pin Nix install version for latest stable branch 2022-02-20 14:24:07 -08:00
Ivan Petkov
762784a8c5
Add compatibility fallback for builtins.groupBy 2022-02-20 14:20:21 -08:00
Ivan Petkov
b4b51464e8
Update changelog 2022-02-18 18:19:05 -08:00
Ivan Petkov
a2449b5aaf
Merge pull request #14 from ipetkov/git-ref
Fix handling of git repos whose rev is not on the main branch
2022-02-19 02:18:44 +00:00
Ivan Petkov
f8d1e70dfc
Fix handling of git repos whose rev is not on the main branch
* When Nix fetches a git repo it will only look for the specified
  revision only starting from the main branch (apparently fetching
  arbitrary revisions from a repository has some security implications)
* If a ref (i.e. branch or tag) is not specified, Nix will only fetch
  the repo's main branch
* To remedy this we will supply Nix with the branch or tag (if specified
  in the Cargo.lock) to help it find the specified revision
* If cargo does not specify a branch or tag for us, we'll set `allRefs =
  true` so that Nix can try fetching all possible branches and tags
  before trying to check out the locked revision
2022-02-18 18:10:53 -08:00
Ivan Petkov
196ab9d45d
Update changelog 2022-02-17 18:16:34 -08:00
Ivan Petkov
39cb921d43
flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/5efc8ca954272c4376ac929f4c5ffefcc20551d5' (2022-01-28)
  → 'github:NixOS/nixpkgs/19574af0af3ffaf7c9e359744ed32556f34536bd' (2022-02-16)
• Updated input 'utils':
    'github:numtide/flake-utils/846b2ae0fc4cc943637d3d1def4454213e203cba' (2022-01-20)
  → 'github:numtide/flake-utils/3cecb5b042f7f209c56ffd8371b2711a290ec797' (2022-02-07)
2022-02-17 18:15:34 -08:00