-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NixOS Module #22
Comments
Hi @j0hax, thanks for the suggestion. It would definitely be nice to add a derivation to Nixpkgs. I’ll certainly do that at some point in the near future. For now, you can use the same configuration as is running on https://bin.gy/ { config, pkgs, lib, ... }:
let
bin = pkgs.rustPlatform.buildRustPackage rec {
pname = "bin";
version = "2.0.0";
src = pkgs.fetchFromGitHub {
owner = "w4";
repo = "bin";
rev = "057ed640ee503469fe4c3b0c164aa1b1bffc6cc6";
sha256 = "1g67k9m4aflhf2sb2xggh896xgp9vh7n2z0w5kxql0p3xa0shsi9";
};
cargoSha256 = "1v2ks2vdr5knn6kri0d03rvzx1mkv5qhv7xphsxpwfyykhbc0j7h";
LIBCLANG_PATH="${pkgs.llvmPackages.libclang}/lib";
};
in {
containers.bin = {
autoStart = true;
ephemeral = true;
macvlans = [ "vlan101" ];
config = { config, pkgs, ... }:
{
networking = {
interfaces.mv-vlan101.ipv4.addresses = [ { address = "10.0.64.106"; prefixLength = 24; } ];
defaultGateway = "10.0.64.2";
nameservers = [ "10.0.64.1" ];
firewall.allowedTCPPorts = [ 8080 ];
};
systemd.services.bin = {
enable = true;
unitConfig = {
After = "network-online.target";
Wants = "network-online.target systemd-networkd-wait-online.service";
};
serviceConfig = {
Type = "exec";
ExecStart = "${bin}/bin/bin 0.0.0.0:8080";
Restart = "on-failure";
};
wantedBy = ["default.target"];
};
};
};
} |
Hi @j0hax, MR is open at NixOS/nixpkgs#165488 - hopefully it'll be merged soon |
Excellent, thanks! |
Any updates on this? There was a review on Apr 4. |
Hi, there's a flake included instead now: {
inputs.paste-bin = {
url = "github:w4/bin";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { ... }:
{
nixosConfigurations.myBox = nixpkgs.lib.nixosSystem {
modules = [
paste-bin.nixosModules.x86_64-linux.default
{
services.paste-bin = {
enable = true;
bindAddress = "[::]:8080";
};
}
];
};
}
} |
Thanks for the quick response. I'm new to nix and haven't used flakes before. From what I understand, with flakes, I would want to add the experimental flags to my configs Afterwards run it like so: Are there any differences apart from how I run it? Also, is there a reason why this isn't simply added to the package repository of nix? |
No problem. If you're just using Nix imperatively you can use It's a little bit better for devs to just include flakes with their packages along with cachix so you're always up to date and not waiting on Hydra whenever a new version is pushed. |
Oh, I see. Thanks. I followed the instructions on their website, but that must refer to the "stable" and not the "experimental" approach. The settings for the flake do not seem to work. I can pass the arguments to the program like this:
But it complains when I try to use the option from the flake:
Am I missing something? Also, it might help some people if this were shown in the README.md. Simply something like this as an example would be a great starting off point for people unfamiliar with nix I think: But I agree allowing for devs to include their own flake definition in their repos, like with Dockerfiles makes it much easier to support for the dev. Great addition. |
That module is only for declarative usage of the service through your configuration.nix unfortunately. You'll have to pass the arguments manually like they're substituted into the systemd execstart
|
I see. Thanks. |
Considering there's already a Nix example in the README, would it be possible to have an official derivation for Nixpkgs and a module to enable it as a service?
I would love to have this up and running on my NixOS-based server!
Cheers
The text was updated successfully, but these errors were encountered: