set up environment
This commit is contained in:
parent
d2b2b730cc
commit
dab145d2d4
6 changed files with 116 additions and 25 deletions
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"rust-analyzer.linkedProjects": [
|
||||
"./helloworld/Cargo.toml",
|
||||
]
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
[workspace]
|
||||
members = ["helloworld"]
|
||||
members = ["day1"]
|
||||
resolver = "2"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "helloworld"
|
||||
name = "day1"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
96
flake.lock
Normal file
96
flake.lock
Normal file
|
@ -0,0 +1,96 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1701253981,
|
||||
"narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681358109,
|
||||
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701397143,
|
||||
"narHash": "sha256-nYUJxZXwCWWVBYZXPgRxGDuQcZRhKTtD/Jp5Jl+9EWU=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "bb71557c93cad40f5921b2342d7fd69f9e6497ab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
36
flake.nix
36
flake.nix
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
TODO
|
||||
1. Find and replace "helloworld" with your package name for **ALL FILES IN REPOSITORY**
|
||||
1. Find and replace "day1" with your package name for **ALL FILES IN REPOSITORY**
|
||||
2. Add a flake description that describes the workspace on line 27
|
||||
3. Add a package description on line 70
|
||||
4. (optional) uncomment `nativeBuildInputs` and `buildInputs` on lines 43 and 44 if you need openssl
|
||||
|
@ -13,8 +13,8 @@ TODO
|
|||
Some utility commands:
|
||||
- `nix flake update --commit-lock-file`
|
||||
- `nix flake lock update-input <input>`
|
||||
- `nix build .#helloworld` or `nix build .`
|
||||
- `nix run .#helloworld` or `nix run .`
|
||||
- `nix build .#day1` or `nix build .`
|
||||
- `nix run .#day1` or `nix run .`
|
||||
*/
|
||||
|
||||
{
|
||||
|
@ -53,17 +53,17 @@ Some utility commands:
|
|||
cargo-edit
|
||||
bacon
|
||||
];
|
||||
inputsFrom = with self.packages.${system}; [ helloworld ];
|
||||
inputsFrom = with self.packages.${system}; [ day1 ];
|
||||
};
|
||||
packages.${system} = {
|
||||
default = self.packages.${system}.helloworld;
|
||||
helloworld = pkgs.rustPlatform.buildRustPackage (rustSettings // {
|
||||
pname = "helloworld";
|
||||
default = self.packages.${system}.day1;
|
||||
day1 = pkgs.rustPlatform.buildRustPackage (rustSettings // {
|
||||
pname = "day1";
|
||||
version = "0.1.0";
|
||||
buildAndTestSubdir = "helloworld";
|
||||
buildAndTestSubdir = "day1";
|
||||
cargoHash = "sha256-+TaGIiKf+Pz2bTABeG8aCZz0/ZTCKl5398+qbas4Nvo=";
|
||||
meta = meta // {
|
||||
description = "";
|
||||
description = "Advent of code solution: day 1";
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@ -71,14 +71,14 @@ Some utility commands:
|
|||
nixosModules.default = { config, ... }: let
|
||||
lib = nixpkgs.lib;
|
||||
in {
|
||||
options.services.helloworld = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc "helloworld service");
|
||||
options.services.day1 = {
|
||||
enable = lib.mkEnableOption (lib.mdDoc "day1 service");
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = self.packages.${system}.helloworld;
|
||||
defaultText = "pkgs.helloworld";
|
||||
default = self.packages.${system}.day1;
|
||||
defaultText = "pkgs.day1";
|
||||
description = lib.mdDoc ''
|
||||
The helloworld package that should be used.
|
||||
The day1 package that should be used.
|
||||
'';
|
||||
};
|
||||
port = lib.mkOption {
|
||||
|
@ -89,16 +89,16 @@ Some utility commands:
|
|||
'';
|
||||
};
|
||||
};
|
||||
config.systemd.services.helloworld = let
|
||||
cfg = config.services.helloworld;
|
||||
pkg = self.packages.${system}.helloworld;
|
||||
config.systemd.services.day1 = let
|
||||
cfg = config.services.day1;
|
||||
pkg = self.packages.${system}.day1;
|
||||
in lib.mkIf cfg.enable {
|
||||
description = pkg.meta.description;
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = ''
|
||||
${cfg.package}/bin/helloworld --port ${builtins.toString cfg.port}
|
||||
${cfg.package}/bin/day1 --port ${builtins.toString cfg.port}
|
||||
'';
|
||||
Restart = "always";
|
||||
DynamicUser = true;
|
||||
|
|
Loading…
Reference in a new issue