Created
July 15, 2025 07:44
-
-
Save tfc/970a050e3ac814270545489f85431efb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, ... }: | |
{ | |
imports = [ | |
./hello-as-a-service.nix | |
]; | |
# variante A | |
# nixpkgs.overlays = [ | |
# (final: prev: { | |
# hello = prev.hello.overrideAttrs (old: { | |
# doCheck = false; | |
# prePatch = '' | |
# substituteInPlace src/hello.c --replace-fail ", world" ", BWI" | |
# ''; | |
# }); | |
# }) | |
# ]; | |
# variante B | |
services.hello.package = pkgs.hello.overrideAttrs (old: { | |
doCheck = false; | |
prePatch = '' | |
substituteInPlace src/hello.c --replace-fail ", world" ", BWI" | |
''; | |
}); | |
services.hello.enable = true; | |
networking.firewall.enable = true; | |
system.stateVersion = "22.11"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
sources = import ./npins; | |
pkgs = import sources.nixpkgs { }; | |
nixosEvaluation = pkgs.nixos [ | |
./configuration.nix | |
./qemu-vm.nix | |
./hello-foo.nix | |
]; | |
in | |
nixosEvaluation.config.system.build.vm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, lib, ... }: | |
let | |
cfg = config.services.hello; | |
in | |
{ | |
options.services.hello = { | |
enable = lib.mkEnableOption "GNU-Hello as a Service"; | |
port = lib.mkOption { | |
type = lib.types.port; | |
default = 8081; | |
description = "Port to listen on"; | |
}; | |
package = lib.mkOption { | |
type = lib.types.package; | |
default = pkgs.hello; | |
}; | |
}; | |
config = lib.mkIf cfg.enable { | |
systemd.services.hello = { | |
description = "Friendly GNU-Hello as a Service Daemon"; | |
wantedBy = [ "multi-user.target" ]; | |
serviceConfig.ExecStart = ''${pkgs.socat}/bin/socat \ | |
TCP4-LISTEN:${builtins.toString cfg.port},reuseaddr,fork \ | |
EXEC:${cfg.package}/bin/hello | |
''; | |
}; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, lib, ... }: { | |
services.hello.package = lib.mkForce (pkgs.hello.overrideAttrs (old: { | |
doCheck = false; | |
prePatch = '' | |
substituteInPlace src/hello.c --replace-fail ", world" ", foobar" | |
''; | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment