set up basic nix build

pull/2/head
Nickiel12 1 year ago
parent 7677eb1425
commit d8ee5d076e

@ -1,9 +1,5 @@
/* /*
TODO TODO
1. Find and replace "helloworld" 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
5. (optional) set your project homepage, license, and maintainers list on lines 48-51 5. (optional) set your project homepage, license, and maintainers list on lines 48-51
6. (optional) uncomment the NixOS module and update it for your needs 6. (optional) uncomment the NixOS module and update it for your needs
7. Delete this comment block 7. Delete this comment block
@ -13,18 +9,18 @@ TODO
Some utility commands: Some utility commands:
- `nix flake update --commit-lock-file` - `nix flake update --commit-lock-file`
- `nix flake lock update-input <input>` - `nix flake lock update-input <input>`
- `nix build .#helloworld` or `nix build .` - `nix build .#nicks_nextcloud_integrations` or `nix build .`
- `nix run .#helloworld` or `nix run .` - `nix run .#nicks_nextcloud_integrations` or `nix run .`
Updating `cargoHash`: Updating `cargoHash`:
- Set `cargoHash` to an empty string - Set `cargoHash` to an empty string
- run `nix run .#helloworld` - run `nix run .#nicks_nextcloud_integrations`
- Update `cargoHash` with correct hash from output - Update `cargoHash` with correct hash from output
rust-project TODO: write shell script for automatically updating `cargoHash` rust-project TODO: write shell script for automatically updating `cargoHash`
*/ */
{ {
description = ""; description = "A group of utilities Nick created to manage his server through nextcloud notes";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@ -59,58 +55,57 @@ rust-project TODO: write shell script for automatically updating `cargoHash`
openssl openssl
bacon bacon
]; ];
inputsFrom = with self.packages.${system}; [ helloworld ]; inputsFrom = with self.packages.${system}; [ status_cloud ];
}; };
packages.${system} = { packages.${system} = {
default = self.packages.${system}.helloworld; status_cloud = pkgs.rustPlatform.buildRustPackage (rustSettings // {
helloworld = pkgs.rustPlatform.buildRustPackage (rustSettings // { pname = "status_cloud";
pname = "helloworld";
version = "0.1.0"; version = "0.1.0";
buildAndTestSubdir = "helloworld"; buildAndTestSubdir = "status_cloud";
cargoHash = "sha256-+TaGIiKf+Pz2bTABeG8aCZz0/ZTCKl5398+qbas4Nvo="; cargoHash = "sha256-GpAWrgFBzOTBCfZy/Ehy7IszuSgSOc/4N
2gbeed0jqI=";
meta = meta // { meta = meta // {
description = ""; description = "Server status saved to a nextcloud note service.";
}; };
}); });
}; };
/*
nixosModules.default = { config, ... }: let nixosModules.default = { config, ... }: let
lib = nixpkgs.lib; lib = nixpkgs.lib;
in { in {
options.services.helloworld = { # status_cloud
enable = lib.mkEnableOption (lib.mdDoc "helloworld service"); options.services.status_cloud = {
enable = lib.mkEnableOption (lib.mdDoc "status_cloud service");
package = lib.mkOption { package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = self.packages.${system}.helloworld; default = self.packages.${system}.status_cloud;
defaultText = "pkgs.helloworld"; defaultText = "pkgs.status_cloud";
description = lib.mdDoc '' description = lib.mdDoc ''
The helloworld package that should be used. The status_cloud package that should be used.
''; '';
}; };
port = lib.mkOption { port = lib.mkOption {
type = lib.types.port; type = lib.types.port;
default = 8000; default = 3001;
description = lib.mdDoc '' description = lib.mdDoc ''
The port at which to run. The port at which to run.
''; '';
}; };
}; };
config.systemd.services.helloworld = let config.systemd.services.status_cloud = let
cfg = config.services.helloworld; cfg = config.services.status_cloud;
pkg = self.packages.${system}.helloworld; pkg = self.packages.${system}.status_cloud;
in lib.mkIf cfg.enable { in lib.mkIf cfg.enable {
description = pkg.meta.description; description = pkg.meta.description;
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "network.target" ]; wantedBy = [ "network.target" ];
serviceConfig = { serviceConfig = {
ExecStart = '' ExecStart = ''
${cfg.package}/bin/helloworld --port ${builtins.toString cfg.port} ${cfg.package}/bin/status_cloud --port ${builtins.toString cfg.port}
''; '';
Restart = "always"; Restart = "always";
DynamicUser = true; DynamicUser = true;
}; };
}; };
}; };
*/
}; };
} }

Loading…
Cancel
Save