Skip to content

Commit Nix lockfiles - #139

Merged
NickLarsenNZ merged 12 commits into
mainfrom
feature/commit-nix-lockfiles
Feb 6, 2024
Merged

NickLarsenNZ merged 12 commits into
mainfrom
feature/commit-nix-lockfiles

Conversation

@nightkr

@nightkr nightkr commented Nov 7, 2023 •

Copy link
Copy Markdown
Contributor

Description

This should allow users to build the package via import-from-derivation, like so:

{ lib, pkgs, ... }:
with lib;
let
  stackablectl = (import (pkgs.fetchFromGitHub {
    owner = "stackabletech";
    repo = "stackable-cockpit";
    rev = "062defa4da2ec504c39d3a21916e871fd95d03f6";
    hash = "sha256-Oq8BhByYDptW84551Rodi6T7MwI8e/6dxIX7p0xNK+A="; # use lib.fakeHash to find new hashes when upgrading
  }) {}).cargo.workspaceMembers.stackablectl.build;
in
{
  packages = with pkgs; [
    stackablectl
    # ...
  ];

  // ...
}

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes
# Author
- [ ] Changes are OpenShift compatible
- [ ] CRD changes approved
- [ ] Helm chart can be installed and deployed operator works
- [ ] Integration tests passed (for non trivial changes)
# Reviewer
- [ ] Code contains useful comments
- [ ] (Integration-)Test cases added
- [ ] Documentation added or updated
- [ ] Changelog updated
- [ ] Cargo.toml only contains references to git tags (not specific commits or branches)
# Acceptance
- [ ] Feature Tracker has been updated
- [ ] Proper release label has been added

Once the review is done, comment bors r+ (or bors merge) to merge. Further information

@nightkr

nightkr commented Nov 7, 2023

Copy link
Copy Markdown
Contributor Author

Nix can't seem to build -rc3. Need to figure out what's going wrong...

@nightkr
nightkr marked this pull request as draft November 10, 2023 11:50
@NickLarsenNZ NickLarsenNZ self-assigned this Jan 10, 2024
@NickLarsenNZ
NickLarsenNZ marked this pull request as ready for review January 10, 2024 11:40
@NickLarsenNZ
NickLarsenNZ requested a review from a team January 10, 2024 11:41
@NickLarsenNZ

NickLarsenNZ commented Jan 10, 2024 •

Copy link
Copy Markdown
Member

Nix can't seem to build -rc3. Need to figure out what's going wrong...

This works for me now (after merging the latest changes in), and I can now run 23.11.3

@NickLarsenNZ
NickLarsenNZ removed the request for review from a team January 10, 2024 12:18
@lfrancke

Copy link
Copy Markdown
Member

@soenkeliebau when you find the time to look at this...

Or can anyone else pick this up as well?

@NickLarsenNZ

NickLarsenNZ commented Jan 26, 2024 •

Copy link
Copy Markdown
Member

@siegfriedweber are you able to review?
I'm unsure who else is using nix

@soenkeliebau

Copy link
Copy Markdown
Member

I got this error when running make run-dev, not sure if my setup is at fault here yet..

Running rustc --crate-name build_script_build build.rs --crate-type bin -C debuginfo=2 -C codegen-units=1 --edition 2021 --cfg feature="default" --out-dir target/build/stackable-cockpit-web --emit=dep-info,link -L dependency=target/buildDeps --extern phf_codegen=/nix/store/bcybvdlpysqpnwgjzqrm2vjqbqagxpq7-rust_phf_codegen-0.11.2-lib/lib/libphf_codegen-643f4bedd5.rlib --cap-lints allow --color always
warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
warning Skipping preferred cache folder "/homeless-shelter/.cache/yarn" because it is not writable.
warning Selected the next writable cache folder in the list, will be "/build/.yarn-cache-1000".
warning Cannot find a suitable global folder. Tried these: "/usr/local, /homeless-shelter/.yarn"
failed to load config from /build/source/vite.config.ts
error during build:
Error: Cannot find module '@babel/core'
Require stack:
- /nix/store/f6f7598fh8pf8k6qkdvsh0mcsnxfwwl5-babel-helper-replace-supers-7.22.9/pkgs/babel-helper-replace-supers@7.22.9/node_modules/@babel/helper-replace-supers/lib/index.js
- /nix/store/v9iwpfarmnw4bm26awqqwhg481khhm46-babel-helper-create-class-features-plugin-7.22.10/pkgs/babel-helper-create-class-features-plugin@7.22.10/node_modules/@babel/helper-create-class-features-plugin/lib/fields.js
- /nix/store/v9iwpfarmnw4bm26awqqwhg481khhm46-babel-helper-create-class-features-plugin-7.22.10/pkgs/babel-helper-create-class-features-plugin@7.22.10/node_modules/@babel/helper-create-class-features-plugin/lib/index.js
- /nix/store/kh2c9p398594zamnj16785sfmvx0h3hy-babel-plugin-transform-typescript-7.22.10/pkgs/babel-plugin-transform-typescript@7.22.10/node_modules/@babel/plugin-transform-typescript/lib/index.js
- /nix/store/ib3m357m422mnjx925wxqh7h6vbg7j9q-babel-preset-typescript-7.22.5/pkgs/babel-preset-typescript@7.22.5/node_modules/@babel/preset-typescript/lib/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/nix/store/f6f7598fh8pf8k6qkdvsh0mcsnxfwwl5-babel-helper-replace-supers-7.22.9/pkgs/babel-helper-replace-supers@7.22.9/node_modules/@babel/helper-replace-supers/lib/index.js:10:13)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
error Command failed with exit code 1.
thread 'main' panicked at build.rs:29:9:
web-ui build failed: exit status: 1
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: build_script_build::main
             at ./build.rs:29:9
   3: core::ops::function::FnOnce::call_once
             at /build/rustc-1.73.0-src/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: builder for '/nix/store/wxfl2lz37ji2y2yigpqd70ymkaf5pmkc-rust_stackable-cockpit-web-0.0.0-dev.drv' failed with exit code 101;
       last 10 log lines:
       > thread 'main' panicked at build.rs:29:9:
       > web-ui build failed: exit status: 1
       > stack backtrace:
       >    0: rust_begin_unwind
       >    1: core::panicking::panic_fmt
       >    2: build_script_build::main
       >              at ./build.rs:29:9
       >    3: core::ops::function::FnOnce::call_once
       >              at /build/rustc-1.73.0-src/library/core/src/ops/function.rs:250:5
       > note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
       For full logs, run 'nix log /nix/store/wxfl2lz37ji2y2yigpqd70ymkaf5pmkc-rust_stackable-cockpit-web-0.0.0-dev.drv'.
error: 1 dependencies of derivation '/nix/store/r6mcqm5i0i4znysyasv0hs1lfz3l1lyr-rust_stackable-cockpitd-0.0.0-dev.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gh006mj90m3l8x2rg7qljiamndgphzbk-stackable-cockpit-base.json.drv' failed to build
error: 1 dependencies of derivation '/nix/store/5yslm9c2saxl9j996fl4vj5m7hmp1nyh-stackable-cockpit-customisation-layer.drv' failed to build
error: 1 dependencies of derivation '/nix/store/6h89rpv8i7vc0air5hnsimvp4p9x286q-stackable-cockpit-conf.json.drv' failed to build
error: 1 dependencies of derivation '/nix/store/glslwicxsfxs03l9iabc3nqrbxlwig9j-stream-stackable-cockpit-image-tag.drv' failed to build
error: 1 dependencies of derivation '/nix/store/sz2rxdkz9hb9p5py1kdb46hxjzh9brf6-stackable-cockpit-docker.drv' failed to build 

@NickLarsenNZ

NickLarsenNZ commented Jan 31, 2024 •

Copy link
Copy Markdown
Member

Thanks @soenkeliebau, I'll see if I can figure that out out and maybe have a few others to test to rule out your machine and my machine.

@NickLarsenNZ

Copy link
Copy Markdown
Member

Hi @soenkeliebau, I was not able to reproduce the same error you got, however I have updated nix packages and regenerated the cargo nix.

Are you able to test it out as follows (you will need to install niv):

Make an empty directory, initialized niv, and added stackable-cockpit:

mkdir /tmp/test-stackable-nix
cd /tmp/test-stackable-nix
niv init
niv add stackabletech/stackable-cockpit -b feature/commit-nix-lockfiles

Then make a shell.nix:

let
  sources = import ./nix/sources.nix;
  pkgs = import sources.nixpkgs {};
  stackable-cockpit = import sources.stackable-cockpit {};

  stackablectl = stackable-cockpit.cargo.workspaceMembers.stackablectl.build;
in
  pkgs.mkShell rec {
    name = "dummy";
    packages = [
      stackablectl
    ];
  }

Then run nix-shell --run 'stackablectl --version'.
You should see the following output:

stackablectl 23.11.3

Alternative method without niv

If you want to try based on the way in the PR description (manual revision and content ID), then here are the updated ones I am using:

{ lib, pkgs, ... }:
with lib;
let
  stackablectl = (import (pkgs.fetchFromGitHub {
    owner = "stackabletech";
    repo = "stackable-cockpit";
    rev = "75d8d970067b8670e089f350eee4be00018464ca";
    hash = "sha256-1qb1hv32h4d3gh5kap0jiyl65wsny0k59mm5fpv3lm7gmcwmk8ya";
  }) {}).cargo.workspaceMembers.stackablectl.build;
in
{
  packages = [
    stackablectl
    # ...
  ];

  // ...
}

@soenkeliebau

Copy link
Copy Markdown
Member

I followed the niv workflow and got the expected result:

[nix-shell:~/test/test-stackable-nix]$ nix-shell --run 'stackablectl --version'
stackablectl 23.11.3

@soenkeliebau soenkeliebau self-assigned this Feb 6, 2024
@NickLarsenNZ
NickLarsenNZ added this pull request to the merge queue Feb 6, 2024
Merged via the queue into main with commit d885d3c Feb 6, 2024
@NickLarsenNZ
NickLarsenNZ deleted the feature/commit-nix-lockfiles branch February 6, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants