Civet icon indicating copy to clipboard operation
Civet copied to clipboard

feat: add nix packages and devshell

Open kasimeka opened this issue 4 months ago • 5 comments

this flake lets nix users

  • run the civet cli with nix run github:danielxmoore/civet or nix run github:danielxmoore/civet#cli
  • run the lsp with nix run github:danielxmoore/civet#ls -- --stdio.
  • install the vscode extension into their nix defined vscode configs (from the vscode-extension output),
  • or compile it into a vsix withnix build github:danielxmoore/civet#vscode-vsix

it also adds a devshell that can be enabled with nix develop github:danielxmoore/civet to get in an ephemeral environment that exposes nodejs, yarn and the exact same versions of bash, sed and any other build requirements as they're locked by flake.lock.

kasimeka avatar Jul 21 '25 07:07 kasimeka

all the maintenance effort this adds is updating yarnDepsHash whenever any corresponding yarn.lock file is modified, seems like there isn't a straightforward document i can link for this but i'll write another comment with instructions within the day

kasimeka avatar Jul 21 '25 08:07 kasimeka

to update yarnDepsHash after modifying yarn.lock files a maintainer should

  1. omit the yarnDepsHash field from mkCivetPackage's arguments for their package
  2. build the target package with nix build .#<output-name>
  3. wait for the new dependencies to be downloaded and hashed, an expected error will be emitted from this step as follows:
    error: hash mismatch in fixed-output derivation '/nix/store/sgqsgja2ax43633r4jjdvh9inb8inxqj-offline.drv':
             specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
                got:    sha256-pEpST+ZWDJYzIaxeb4ou8rLtNwgnKv0SdahHJ15bgn8=
    error: Cannot build '/nix/store/vwm5gkrk9gl26s26vgkmcyji7barafv1-civet-0.10.5.drv'.
           Reason: 1 dependency failed.
           Output paths:
             /nix/store/1fkmcwawv0zzkaninsy90nynci314i5q-civet-0.10.5
    
  4. copy the value of "got", which in this example is sha256-pEpST+ZWDJYzIaxeb4ou8rLtNwgnKv0SdahHJ15bgn8= and use it as the new yarnDepsHash
  5. rerun the build step after updating the hash and commit the change after it builds successfully

there are tools that attempt to automate this process but i don't find any of them convenient enough to use.

kasimeka avatar Jul 21 '25 14:07 kasimeka

We could probably make a bash script that automates the update.

STRd6 avatar Jul 22 '25 14:07 STRd6

@STRd6, i added an update script

kasimeka avatar Jul 26 '25 18:07 kasimeka

the cli issue should be fixed now. it was based on a misunderstanding on my end of how the cli is bundled. now instead of overriding the installPhase added by yarnInstallHook i moved the entrypoint creation code to a fixupPhase that runs after the installation code. this results in a civet cli entrypoint that has access to node_modules during runtime.

kasimeka avatar Aug 15 '25 17:08 kasimeka