I’m currently running issues in deploying an app on a NixOS server.
What I’m trying to do is have a NixOS server running that pulls in a website repo that has a flake that specifies how to run the site.
But no matter how I try to make it work, instead of running the commands in the folder where the website code resides, it pulls it into the Nix store and then cannot find the flake file.
The repo with the Nix code that specifies systemd services to run can be found here:
This repo contains my website code, since I couldn’t get submodules to work, and the website also pulls in another Haskell utility with a flake to run it: here
Are there examples, or is there a known way to incorporate and run flake outputs in a NixOS system? I don’t necessarily want to add all the apps on the server as inputs to the flake.nix, but will if I have to.
This is one of the most common confusions around flakes. To evaluate your flake, nix will first copy the directory (either $PWDor the root of your git repo, including only files that have been git add-ed) into the nix store. There is no way around this, and your directory must have a flake.nix.
Why are you trying to make nix not do that? I don’t fully understand your use case.
The way to do that is to add the flake as an input to the system flake, and to use the outputs as usual, indeed. I’m not sure what you’re envisioning otherwise, what would you like it to be?
What I’m trying to do is declaratively specify a NixOS server using a flake to pull in a configuration.nix file.
I want this server to run and update a blog, reacting to new posts and regenerating the blog outline.
But since flakes pull everything into the store, I am unable to correctly write the systemd services that run the blog commands. The sandbox has no utilities, so I cannot even do a nix run on my blog flake.
Is managing a server that runs and updates apps something better suited to NixOps?
ok, couldn’t you use autoUpgrade.flake and specify in autoUpgrade.flags [“–update-input” “myflake” “–commit-lock-file”] and then in your nixos server just specify your server normally. the problem to this approach is that you need to update the flake but i do hope that is easier