Hi there!
I’m trying to create a Flake that does the following:
- builds and packages a Rust executable
- exposes a NixOS module that provides a systemd service to run that executable (In my real project, it’s an HTTP server, but for this example it’s just a simple ‘Hello world!’).
I think I have managed the first step, but I’m struggling with the second step.
I’ve cut down the size of my project and reduced it to this minimum example: experiments/hallo-nix-flakes: Attempt to create a flake - hallo-nix-flakes - Gitea and biscuits
My biggest problem so far is that I don’t know what to specify as the entry point (in experiments/hallo-nix-flakes: Attempt to create a flake - nix_flake/modules/halloSvc.nix at master - hallo-nix-flakes - Gitea and biscuits); I’ve tried:
ExecStart = ''${pkgs.hallo}/bin/hallo'';
and
ExecStart = ''${hallo.hallo}/bin/hallo'';
both give me ‘attribute hallo
missing’ errors.
Please could I have some pointers on how to do this properly? I would also really appreciate links to example flakes that package an application + NixOS service module, because I would ideally like to figure out how to not only get this working, but also how to do it idiomatically/cleanly as well :-).
There are README.md
files in nix_flake
and nix_flake/test_vm
with the commands I’m using to build/test; crucially what I’m doing to test my module is:
cd nix_flake/test_vm
nix flake update
nix build .#nixosConfigurations.testvm.config.system.build.vm -j8
./result/bin/run-nixos-vm
Thanks!