Jump to content

Devenv: Difference between revisions

From NixOS Wiki
Malix (talk | contribs)
m request expand
Malix (talk | contribs)
merge proposal
 
Line 1: Line 1:
{{Expand|scope=article}}
{{Merge|Development_environment_with_nix-shell|scope=article}}{{Expand|scope=article}}


== Installation ==
== Installation ==

Latest revision as of 14:55, 1 October 2025

⤟︎
This article is a candidate for merging with Development_environment_with_nix-shell. Further information may be found in the relevant discussion page.
☶︎
This article needs to be expanded. Further information may be found in the related discussion page. Please consult the pedia article metapage for guidelines on contributing.

Installation

environment.systemPackages = [
  pkgs.devenv
];

Binding to privileged ports (eg. 80 and 443)

The Wordpress example in the guide suggests the following script:

scripts.caddy-setcap.exec = ''
  sudo setcap 'cap_net_bind_service=+ep' ${pkgs.caddy}/bin/caddy
'';

But this does not work on NixOS. It fails with Failed to set capabilities on file 'setcap': Read-only file system We can work around this by creating a local copy of Caddy, running setcap on that, and then copying the Caddy process exec command but referring it to our local binary.

# This creates a local copy of Caddy that can bind to privileged ports like 80 and 443
scripts.caddy-setcap.exec = lib.mkForce ''
  mkdir -p ./bin
  cp ${pkgs.caddy}/bin/caddy ./bin/caddy
  sudo setcap 'cap_net_bind_service=+ep' ./bin/caddy
'';

# This launces the local Caddy
processes.caddy-local.exec = ''${lib.replaceString "${pkgs.caddy}" "." config.processes.caddy.exec}'';

It is most useful to do this in devenv.local.nix, so your non-NixOS colleagues can still use the default setup.