Skip to content
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/hledger-web: add stateDir, use own user, fix ExecStart #116107

Merged
merged 2 commits into from
Mar 26, 2021

Conversation

erictapen
Copy link
Member

Motivation for this change

This allows for shared hledger installations, where the web interface is available via network and multiple user share a SSH access to the hledger user.

Also added --serve to the CLI options, as hledger-web tries to open a webbrowser otherwise:

hledger-web: xdg-open: rawSystem: runInteractiveProcess: exec: does not exist (No such file or directory)

Things done
  • Added dedicated user. I chose hledger over hledger-web, is this should be useful for users of Hledger in general, not only hledger-web.
  • Added cfg.stateDir
  • Added myself as maintainer.
  • Set cfg.capabilities as booleans, as I messed with shell escaping for too long and this seems more adequate to me.
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@erictapen erictapen requested a review from marijanp March 12, 2021 22:03
@ofborg ofborg bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Mar 12, 2021
@erictapen erictapen force-pushed the hledger-web-statedir branch from 0b31d77 to 9423de7 Compare March 24, 2021 14:48
Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know anything about hledger-web but from a NixOS module point of view looks good 👍

Full bonus points will be awarded if you address the additional review point here.

type = types.path;
example = "/home/hledger/.hledger.journal";
type = types.str;
default = ".hledger.journal";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow this breaking change slipped by me before. You might consider adding a check or assertion that the value here is a file name and not a path+file name. Release notes wouldn't hurt either...

You could probably do better, but at least checking that the name doesn't start with a forward slash could help 🤷‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that would make sense to have. I implemented an assertion:

error:                                                                                                                               
       Failed assertions:                                                                                                            
       - services.hledger-web.journalFile is no longer defined as a path, but                                                        
       as a file name located in services.hledger-web.stateDir.                                                                      

Given that hledger wasn't mentioned once in the NixOS release notes, I'd figure the module isn't used enough to justify an entry?

@erictapen erictapen force-pushed the hledger-web-statedir branch from 9423de7 to f1649a0 Compare March 25, 2021 00:19
'';
};

journalFile = mkOption {
type = types.path;
example = "/home/hledger/.hledger.journal";
type = types.str;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the documentation of hledger-web again, I've seen that you can define multiple journal files using -f hledger-web documentation. We can consider making this a listof strings types.nix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable, I added another commit that makes the change. Removed the assertion with it, as users will see an error with their configuration anyway.

@marijanp I you think it's good I can squash the commit into the first one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good too me.

"--capabilities=${capabilityString}"
(optionalString (cfg.baseUrl != null) "--base-url=${cfg.baseUrl}")
(optionalString (cfg.serveApi) "--serve-api")
] ++ (map (f: "--file=${stateDir}/${f}") cfg.journalFiles)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected that you only need to set -f once, in case somebody is wondering too. But this is correct. -f for each file.

erictapen and others added 2 commits March 26, 2021 13:43
This allows for shared hledger installations, where the web interface is
available via network and multiple user share a SSH access to the
hledger user.

Also added `--serve` to the CLI options, as hledger-web tries to open a
webbrowser otherwise:

hledger-web: xdg-open: rawSystem: runInteractiveProcess: exec: does not
exist (No such file or directory)

Co-authored-by: Aaron Andersen <[email protected]>
@erictapen erictapen force-pushed the hledger-web-statedir branch from e4cbee8 to 55c7cb3 Compare March 26, 2021 12:44
@erictapen
Copy link
Member Author

Squashed and rebased, thanks for the review!

@erictapen erictapen merged commit 347a916 into NixOS:master Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants