Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use nix flake, std, tullia and cicero #176

Merged
merged 4 commits into from
Jan 18, 2023
Merged

Conversation

jbgi
Copy link
Contributor

@jbgi jbgi commented Oct 12, 2022

std-based alternative take to #175.

@jbgi jbgi force-pushed the jbgi/nix-flake-std branch 3 times, most recently from 570476b to 18e3612 Compare October 12, 2022 22:40
@hamishmack
Copy link
Contributor

This looks really good. Is there a way to pass evalSystem to everything? I wanted to see if I could run nix flake show on macOS without using remote builder:

I tried the following, but I think the cross compiled versions of the project are still missing the evalSystem somehow.

diff --git a/cells/_automation/hydraJobs.nix b/cells/_automation/hydraJobs.nix
index 5d101b8..ceb7d5c 100644
--- a/cells/_automation/hydraJobs.nix
+++ b/cells/_automation/hydraJobs.nix
@@ -4,7 +4,7 @@
 }: let
   inherit (inputs.nixpkgs) lib;
   inherit (inputs.cells.prelude.library) project extra-compilers;
-  evalSystem = "x86_64-linux";
+  evalSystem = "x86_64-darwin";

   ciProject = project.appendModule {
     inherit evalSystem;
diff --git a/cells/prelude/library.nix b/cells/prelude/library.nix
index d949a48..9ed335a 100644
--- a/cells/prelude/library.nix
+++ b/cells/prelude/library.nix
@@ -41,6 +41,7 @@
     name = "cardano-prelude";
     inherit src;
     compiler-nix-name = lib.mkDefault default-compiler;
+    evalSystem = "x86_64-darwin";
     # Cross compilation support:
     crossPlatforms = p:
       lib.optionals pkgs.stdenv.hostPlatform.isLinux (
@@ -59,7 +60,7 @@
       # deduce package names from the cabal project to avoid hard-coding them:
       projectPackageNames = builtins.attrNames (haskellLib.selectProjectPackages
         (haskell-nix.cabalProject' {
-          inherit (config) name src compiler-nix-name cabalProjectLocal;
+          inherit (config) name src compiler-nix-name evalSystem cabalProjectLocal;
         })
         .hsPkgs);
     in [

@jbgi
Copy link
Contributor Author

jbgi commented Oct 13, 2022

@hamishmack right, forgot to pass evalSystem here: bb6e26a
nix flake show should work now (with your local modifications).

cells/_automation/hydraJobs.nix Outdated Show resolved Hide resolved
cells/_automation/tasks.nix Outdated Show resolved Hide resolved
cells/_automation/tasks.nix Outdated Show resolved Hide resolved
cells/prelude/apps.nix Outdated Show resolved Hide resolved
@jbgi
Copy link
Contributor Author

jbgi commented Oct 13, 2022

@dermetfan tried your suggestion in last commit, but it is still failing:

$ tullia run ci/hydraJobs.x86_64-linux.roots
...
[✗] error  ci/hydraJobs.x86_64-linux.roots                                                                9m11.235325358s
warning: Git tree '/home/jbgi/Dev/iohk/cardano-prelude' is dirty                                                         
warning: Using saved setting for 'allow-import-from-derivation = true' from ~/.local/share/nix/trusted-settings.json.    
warning: Using saved setting for 'extra-substituters = https://cache.iog.io' from ~/.local/share/nix/trusted-settings.jso
n.                                                                                                                       
warning: Using saved setting for 'extra-trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ='
from ~/.local/share/nix/trusted-settings.json.                                                                           
error (ignored): error: SQLite database '/home/jbgi/.cache/nix/eval-cache-                                               
v4/1553df62b97b634bce22160eed0bb4a05e9e574b5e5e752ad9c22245c16fd86e.sqlite' is busy                                      
error: flake 'git+file:///home/jbgi/Dev/iohk/cardano-prelude' does not provide attribute 'packages.x86_64-               
linux.tullia.x86_64-linux.task.ci/hydraJobs.x86_64-linux.roots.nsjail.run', 'legacyPackages.x86_64-linux.tullia.x86_64-  
linux.task.ci/hydraJobs.x86_64-linux.roots.nsjail.run' or 'tullia.x86_64-linux.task.ci/hydraJobs.x86_64-                 
linux.roots.nsjail.run'                                                                                                  
Failed to run /nix/store/i7zh5x24vsbv471zk7vadkgsa55qianz-nix-2.11.0/bin/nix build --json --no-link .#tullia.x86_64-     
linux.task.ci/hydraJobs.x86_64-linux.roots.nsjail.run: exit status 1

Also another issue is that even though I specify only one task, tullia execute all tasks... (almost crashing my machine: is there a way to limit concurrent jobs?).

@dermetfan
Copy link
Contributor

There was an escaping issue in tullia. Fixed that and updated the tullia flake input.

is there a way to limit concurrent jobs?

I added a tullia task for each hydra job so you can now run them separately like this (without ci/ prefix):

nix run github:input-output-hk/tullia -- run hydraJobs.x86_64-linux.ghc924.plan-nix

@jbgi
Copy link
Contributor Author

jbgi commented Oct 17, 2022

@dermetfan I'm now getting

$ nix run github:input-output-hk/tullia -- run x86_64-linux._automation.ciJobs.ghc924.plan-nix
warning: Using saved setting for 'allow-import-from-derivation = true' from ~/.local/share/nix/trusted-settings.json.
warning: Using saved setting for 'extra-substituters = https://cache.iog.io' from ~/.local/share/nix/trusted-settings.json.
warning: Using saved setting for 'extra-trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=' from ~/.local/share/nix/trusted-settings.json.
[✗] error  x86_64-linux._automation.ciJobs.ghc924.plan-nix                                                  12.778438199s
[E][2022-10-17T14:55:32+0000][1] void subproc::subprocNewProc(nsjconf_t*, int, int, int, int, int)():205                 
execve('/nix/store/zspimn40hjy77c6bdmk24lwam87zwmy2-x86_64-linux._automation.ciJobs.ghc924.plan-nix/bin/'x86_64-         
linux._automation.ciJobs.ghc924.plan-nix'') failed: No such file or directory                                            
[F][2022-10-17T14:55:32+0000][1] bool subproc::runChild(nsjconf_t*, int, int, int, int)():448 Launching child process    
failed                                                                                                                   
[W][2022-10-17T16:55:32+0200][802842] bool subproc::runChild(nsjconf_t*, int, int, int, int)():478 Received error message
from the child process before it has been executed                                                                       
[E][2022-10-17T16:55:32+0200][802842] int nsjail::standaloneMode(nsjconf_t*)():256 Couldn't launch the child process     
Failed to run /nix/store/6cka89h4lly1m068a2lv8i99gvp8a0x6-x86_64-linux._automation.ciJobs.ghc924.plan-nix-nsjail/bin/x86_
64-                                                                                                                      
linux._automation.ciJobs.ghc924.plan-nix-nsjail: exit status 255                                                         
4:55PM FTL starting supervisor error="running x86_64-linux._automation.ciJobs.ghc924.plan-nix: Failed to run /nix/store/6cka89h4lly1m068a2lv8i99gvp8a0x6-x86_64-linux._automation.ciJobs.ghc924.plan-nix-nsjail/bin/x86_64-linux._automation.ciJobs.ghc924.plan-nix-nsjail: exit status 255"

@dermetfan
Copy link
Contributor

That's just nsjail having trouble with cgroups when it tries to actually run the task (not yet well tested). Evaluation and building worked fine so it works on cicero, as for cicero the nomad + oci runtime is used instead of nsjail.

@jbgi jbgi force-pushed the jbgi/nix-flake-std branch 2 times, most recently from 5e107d2 to 5431e2b Compare October 18, 2022 13:29
@jbgi jbgi requested a review from michaelpj October 18, 2022 13:37
.envrc Show resolved Hide resolved
cardano-prelude-test/cardano-prelude-test.cabal Outdated Show resolved Hide resolved
cells/_automation/ciJobs.nix Outdated Show resolved Hide resolved
cells/_automation/ciJobs.nix Show resolved Hide resolved
cells/_automation/devshells.nix Outdated Show resolved Hide resolved
cells/_automation/nixago.nix Show resolved Hide resolved
cells/_automation/tasks.nix Outdated Show resolved Hide resolved
cells/prelude/library.nix Outdated Show resolved Hide resolved
release.nix Outdated Show resolved Hide resolved
cells/prelude/library.nix Outdated Show resolved Hide resolved
@michaelpj
Copy link
Contributor

On reflection, a high-level thought. This PR contains hundreds of lines of nix code providing lots of features, but explains nothing about how to use it or work with it. To put it another way: cardano-prelude needs a CONTRIBUTING, and if we're going to add all this stuff it desperately needs one. What is all this stuff? What is lefthook? What is nixago? What's up with this editorconfig thing? How do I get a shell? How do I update things? What's the CI setup? How do I change the compilers it's testing against? At the moment nobody will know any of this except @jbgi

Yes, that's a lot to write about, but this PR adds a lot of stuff. If we want to keep it minimal instead that would be fine but if we're going to go big IMO we have to document things.

@jbgi
Copy link
Contributor Author

jbgi commented Oct 19, 2022

Sure. Most std stuff can be documented with links to the appropriate std doc page.
I'll work on it next week.

@michaelpj
Copy link
Contributor

I think that's good for maintainers of the nix code, but we also need to document things in a form that's comprehensible by people working on the Haskell code, hence CONTRIBUTING.

@jbgi jbgi force-pushed the jbgi/nix-flake-std branch 5 times, most recently from 82cdc3f to ce8aee6 Compare October 26, 2022 15:08
@jbgi
Copy link
Contributor Author

jbgi commented Oct 26, 2022

@michaelpj added CONTRIBUTING.md in last commit (albeit rather minimal for now, but should be enough to not block any dev workflow).

@dermetfan
Copy link
Contributor

I pushed a fix for the latest tullia version, maybe squash again @jbgi (didn't want to squash and force push to not confuse anybody)

bors.toml Outdated Show resolved Hide resolved
@jbgi jbgi force-pushed the jbgi/nix-flake-std branch 2 times, most recently from 8de0368 to e3434a6 Compare January 9, 2023 15:45
@jbgi jbgi force-pushed the jbgi/nix-flake-std branch 7 times, most recently from f6ccd17 to c8cf8e6 Compare January 12, 2023 14:43
@coot
Copy link
Contributor

coot commented Jan 13, 2023

@erikd, @newhoggy, @lehins are you ok with requiring fourmolu formatter?

@lehins
Copy link
Contributor

lehins commented Jan 13, 2023

are you ok with requiring fourmolu formatter?

@coot I encourage requiring it!

Copy link

@blaggacao blaggacao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the formatter-only changes this will be handy: https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view

Please let me know or open an upstream ticket if you need anything from Standard. Even the ever so slightest improvement ideas are welcome!

# This is a template created by `hix init`
inputs = {
nixpkgs = {
follows = "std/nixpkgs";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the circumstances, it may be better to set, not follow nixpkgs, here. For example, it gives you more control over cache invalidations and decouples them from std.

You still then do std.inputs.nixpkgs.follows.


### Commit message

Commit messages should ideally be of the form `<type>[(<scope>)]: <short description>]` ([conventionnal](https://www.conventionalcommits.org/) commit message). Available commit types are from [std presets](https://std.divnix.com/reference/presets/nixago/conform.html).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up: In my experience, the default scopes (one scope per cell) is often times not enough. So as this is being trained into muscle memory and used by people, I'd suggest at least a refinement on the scopes.

@jbgi jbgi force-pushed the jbgi/nix-flake-std branch 2 times, most recently from e3e90e4 to 7ae03d3 Compare January 17, 2023 13:07
@jbgi jbgi force-pushed the jbgi/nix-flake-std branch 2 times, most recently from cc6b4a0 to 32d8f0f Compare January 18, 2023 09:58
@jbgi
Copy link
Contributor Author

jbgi commented Jan 18, 2023

bors r+

@jbgi jbgi merged commit 94b3748 into master Jan 18, 2023
@dermetfan dermetfan deleted the jbgi/nix-flake-std branch January 19, 2023 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants