many changes I don't remember...

This commit is contained in:
Emile Clark-Boman 2025-02-19 12:14:25 +10:00
parent 20d938a506
commit 0f3a016a3d
19 changed files with 525 additions and 204 deletions

View file

@ -1,44 +0,0 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
flake-utils,
}: {
# TODO: 1. add options (ie one to set whether the server should be enabled),
# 2. create a systemd service
# 3. create a main program
# 4. celibrate
packages = flake-utils.lib.eachDefaultSystem (
system: let
version = "0.15.1";
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
in {
wishlist = pkgs.buildGoModule {
pname = "wishlist";
inherit version;
meta = with lib; {
homepage = "https://github.com/charmbracelet/wishlist";
description = "Your SSH directory.";
license = licenses.mit;
maintainers = with maintainers; [caarlos0];
};
src = pkgs.fetchFromGithub {
owner = "charmbracelet";
repo = "wishlist";
rev = "v${version}"; # TODO: is this ok? should this be a hash instead?
hash = "0c9g1s8j9znzd1mw61d0klc6sqri0wx6hljibxdwzi3cabfy3ld6";
};
vendorSha256 = lib.fakeSha256;
};
}
);
};
}

31
flakes/wishlist/README Normal file
View file

@ -0,0 +1,31 @@
#### wishlist.nix
This is a simple Nix flake defining a service from which
wishlist can run automatically. This flake runs wishlist-0.15.1
and lacks configurability unfortunately. However this was an
intentional choice, allowing wishlist to read from the user's
`~/.ssh/config` file, which can be configured seperately using
the something akin to the follow home-manager snippet:
```nix
programs.ssh = {
enable = true;
addKeysToAgent = "yes"; # always add keys to ssh-agent
matchBlocks = {
hyrule = {
hostname = "imbored.dev";
user = "ae";
port = 22;
identityFile = "/home/me/.ssh/id_hyrule";
};
};
};
```
This decision was mostly selfish as it was easiest...
But it comes at the cost of not being able to set the
port wishlist listens on. So for now you're stuck with `2222`.
###### The Future!! (woooowwww)
Create an option for wishlist that is used to construct
the `config.yaml` file

93
flakes/wishlist/flake.nix Normal file
View file

@ -0,0 +1,93 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
config,
nixpkgs,
lib,
flake-utils,
}: let
cfg = config.services.wishlist;
supportedSystems = ["x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
in {
# TODO: 1. add options (ie one to set whether the server should be enabled),
# 2. create a systemd service
# 3. create a main program
# 4. celibrate
# TODO: do I need to make this a home-manager option and set the yaml config?
# define what settings a user can change
options = {
services.wishlist = with lib; {
enable = mkEnableOption "wishlist";
port = mkOption {
type = types.port;
default = 2222;
description = "Port to listen on";
};
package = mkOption {
type = types.package;
default = self.packages.${nixpkgs.system}.default;
description = "Package to use";
};
};
};
# define a systemd service for wishlist ^_^
config = lib.mkIf cfg.enable {
systemd.services.wishlist = {
description = "Single entrypoint for multiple SSH endpoints";
wantedBy = ["multi-user.target"];
serviceConfig = {
DynamicUser = "yes";
ExecStart = "${cfg.package}/bin/wishlist serve";
Restart = "always";
RestartSec = "2s";
};
};
};
packages = flake-utils.lib.eachSystem supportedSystems (
system: let
version = "0.15.1";
#pkgs = nixpkgs.legacyPackages.${system};
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = false;
};
#lib = pkgs.lib;
in rec {
defaultPackage = self.packages.${system}.wishlist;
wishlist = pkgs.buildGoModule {
pname = "wishlist";
inherit version;
meta = with lib; {
description = "Single entrypoint for multiple SSH endpoints";
homepage = "https://github.com/charmbracelet/wishlist";
changelog = "https://github.com/charmbracelet/wishlist/releases/tag/v${version}";
license = licenses.mit;
maintainers = with maintainers; [caarlos0 penguwin];
mainProgram = "wishlist";
};
src = pkgs.fetchFromGitHub {
owner = "charmbracelet";
repo = "wishlist";
rev = "v${version}";
# rev = "d7f058e115a8b4a4131406d01dde84fb4a8e93c4";
hash = "53fojA+gdvpSVNjx6QncH16F8/x+lpY5SkNs7obW2XQ=";
};
vendorSha256 = "0x6rss3fwv2398wrd5kyzkrqaphzvh4ykwfqai9glxm01y6fhxz7";
};
}
);
};
}

View file

@ -0,0 +1,99 @@
# NOTE: Wishlist service fails on nix because of readonly file system
# and it can't find a config file for itself, it needs to write that
# itself I suppose :(
# So:
# 1. Get it to write that file, and
# 2. Allow it to inherit profiles from configured ssh
{
self,
config,
pkgs,
lib,
}: let
cfg = config.services.wishlist;
in {
options = {
services.wishlist = with lib; {
enable = mkEnableOption "wishlist";
name = mkOption {
type = types.str;
default =
};
port = mkOption {
type = types.port;
default = 2222;
description = "Port to listen on";
};
#configPath = mkOption {
# type = types.path;
# default = ;
# description = "Path to config file";
#};
package = mkOption {
type = types.package;
default = self.packages.${nixpkgs.system}.default;
description = "Package to use";
};
};
};
# define a systemd service for wishlist ^_^
config = lib.mkIf cfg.enable {
systemd.services.wishlist = {
description = "Single entrypoint for multiple SSH endpoints";
wantedBy = ["multi-user.target"];
serviceConfig = let
wishlistServiceConfig = pkgs.writeText "config.yaml" ''
hello world!
'';
in {
DynamicUser = "yes";
ExecStart = "${pkgs.wishlist}/bin/wishlist serve --config ${wishlistServiceConfig}";
Restart = "always";
RestartSec = "2s";
};
};
};
/*
packages = flake-utils.lib.eachSystem supportedSystems (
system: let
version = "0.15.1";
#pkgs = nixpkgs.legacyPackages.${system};
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = false;
};
#lib = pkgs.lib;
in rec {
defaultPackage = self.packages.${system}.wishlist;
wishlist = pkgs.buildGoModule {
pname = "wishlist";
inherit version;
meta = with lib; {
description = "Single entrypoint for multiple SSH endpoints";
homepage = "https://github.com/charmbracelet/wishlist";
changelog = "https://github.com/charmbracelet/wishlist/releases/tag/v${version}";
license = licenses.mit;
maintainers = with maintainers; [caarlos0 penguwin];
mainProgram = "wishlist";
};
src = pkgs.fetchFromGitHub {
owner = "charmbracelet";
repo = "wishlist";
rev = "v${version}";
# rev = "d7f058e115a8b4a4131406d01dde84fb4a8e93c4";
hash = "53fojA+gdvpSVNjx6QncH16F8/x+lpY5SkNs7obW2XQ=";
};
vendorSha256 = "0x6rss3fwv2398wrd5kyzkrqaphzvh4ykwfqai9glxm01y6fhxz7";
};
}
);
*/
}