Skip to content

Commit

Permalink
nix: flakify
Browse files Browse the repository at this point in the history
  • Loading branch information
goffrie committed Dec 28, 2024
1 parent 0da2ebc commit ea06f20
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 29 deletions.
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "eframe devShell";
description = "a game about strawberries";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
Expand All @@ -13,6 +13,9 @@
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
in with pkgs; {
packages.client = import ./client { inherit pkgs; };
packages.server = import ./server { inherit pkgs; };

devShells.default = mkShell rec {
buildInputs = [
# Rust
Expand All @@ -24,5 +27,10 @@

LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
};
});
}) // {
nixosModules.default = args@{ pkgs, ... }:
import ./service.nix {
inherit (self.packages."${pkgs.stdenv.targetPlatform.system}") client server;
} args;
};
}
39 changes: 26 additions & 13 deletions server/default.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixpkgs> {
overlays = [
(import ((import <nixpkgs> { }).fetchFromGitHub {
owner = "oxalica";
repo = "rust-overlay";
rev = "784981a9feeba406de38c1c9a3decf966d853cca";
hash = "sha256-as0I9xieJUHf7kiK2a9znDsVZQTFWhM1pLivII43Gi0=";
}))
];
} }:

let
rustPkgs = pkgs // import (pkgs.fetchFromGitHub {
owner = "oxalica";
repo = "rust-overlay";
rev = "784981a9feeba406de38c1c9a3decf966d853cca";
hash = "sha256-as0I9xieJUHf7kiK2a9znDsVZQTFWhM1pLivII43Gi0=";
}) rustPkgs pkgs;
rustc = rustPkgs.rust-bin.stable."1.82.0".default.override { targets = ["x86_64-unknown-linux-musl"]; };
in
(pkgs.rustPlatform.buildRustPackage.override { inherit rustc; }) {
rustc = pkgs.rust-bin.stable."1.82.0".default.override {
targets = [ "x86_64-unknown-linux-musl" ];
};
in (pkgs.rustPlatform.buildRustPackage.override { inherit rustc; }) {
pname = "globby";
version = "0.1.0";
src = pkgs.linkFarm "globby-src" [
{ name = "Cargo.toml"; path = "${./Cargo.toml}"; }
{ name = "Cargo.lock"; path = "${./Cargo.lock}"; }
{ name = "src"; path = "${./src}"; }
{
name = "Cargo.toml";
path = "${./Cargo.toml}";
}
{
name = "Cargo.lock";
path = "${./Cargo.lock}";
}
{
name = "src";
path = "${./src}";
}
];
cargoLock.lockFile = ./Cargo.lock;
checkPhase = "true";
Expand Down
10 changes: 5 additions & 5 deletions service.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ config, pkgs, ... }:
with pkgs.lib;
{ client, server }:
{ config, lib, ... }:
with lib;
let
cfg = config.services.strawberry;
build = import ./build.nix {};
in {
options.services.strawberry = {
listen = mkOption {
Expand All @@ -11,14 +11,14 @@ in {
description = "The address on which to listen";
};
};
config.environment.etc."strawberry/client".source = "${build.client}";
config.environment.etc."strawberry/client".source = "${client}";
config.systemd.services.strawberry = {
description = "Strawberry";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
environment.RUST_BACKTRACE = "1";
serviceConfig = {
ExecStart = "${build.server}/bin/globby ${cfg.listen} /etc/strawberry/client /var/lib/strawberry";
ExecStart = "${server}/bin/globby ${cfg.listen} /etc/strawberry/client /var/lib/strawberry";
StandardOutput = "syslog";
StandardError = "syslog";
SyslogIdentifier = "strawberry";
Expand Down

0 comments on commit ea06f20

Please sign in to comment.