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

Filebrowser service #306615

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

sdellysse
Copy link
Contributor

@sdellysse sdellysse commented Apr 24, 2024

Description of changes

Added service configuration for filebrowser. I'm open to suggestions on how to better structure the options since this application is primarily configured through a mutable single-file database.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/first-pr-anything-else-to-do-or-just-wait/44035/1

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/3852

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/3911

Copy link
Contributor

@MinerSebas MinerSebas left a comment

Choose a reason for hiding this comment

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

Please add the following to the filebrowser package

At the top:

-{ buildGoModule, buildNpmPackage, fetchFromGitHub, lib }:
+{ buildGoModule, buildNpmPackage, fetchFromGitHub, lib, nixosTests }:

And in the lower buildGoModule

   passthru = {
     inherit frontend;
+    tests = {
+      filebrowser = nixosTests.filebrowser;
+    };
   };

This would have let the CI catch the other mistakes.

nixos/tests/filebrowser.nix Outdated Show resolved Hide resolved
nixos/modules/services/misc/filebrowser.nix Outdated Show resolved Hide resolved
nixos/modules/services/misc/filebrowser.nix Outdated Show resolved Hide resolved
@MinerSebas
Copy link
Contributor

MinerSebas commented May 11, 2024

After the above changes i can access the the webpage, but not login.
Presumably the non-standard install doesn't add the bootstrap admin account.
No Problem, i can just confirm this with the users ls command

$ sudo filebrowser-service-tool.sh users ls
2024/05/11 23:12:29 timeout

:-(

Edit:
I needed to run sudo systemctl stop filebrowser.service to perform the action, which confirmed that no users where created. After creating a admin user, everything seems to work correctly.

@sdellysse sdellysse force-pushed the filebrowser-service branch 2 times, most recently from 35edb9d to f4b399f Compare May 14, 2024 17:31
@sdellysse sdellysse marked this pull request as draft May 15, 2024 16:20
@sdellysse sdellysse marked this pull request as ready for review May 15, 2024 17:12
@sdellysse sdellysse force-pushed the filebrowser-service branch 2 times, most recently from a8531aa to 0a5f279 Compare May 15, 2024 18:09
@sdellysse
Copy link
Contributor Author

After the above changes i can access the the webpage, but not login. Presumably the non-standard install doesn't add the bootstrap admin account. No Problem, i can just confirm this with the users ls command

$ sudo filebrowser-service-tool.sh users ls
2024/05/11 23:12:29 timeout

:-(

Edit: I needed to run sudo systemctl stop filebrowser.service to perform the action, which confirmed that no users where created. After creating a admin user, everything seems to work correctly.

This was a great catch, and I updated the filebrowser-service-tool to be a bit more aware of the peculiarities of how filebrowser works. I also added a note to the services.filebrowser.enable documentation stating that no users will be created by default, and how to do so.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/3982

@h7x4
Copy link
Member

h7x4 commented Jun 1, 2024

Ref #289750, not sure about the differences but maybe the changes can be synced up?

cfg = config.services.filebrowser;

cmd =
"${cfg.package}/bin/filebrowser --config='${cfg.dataDir}/config.json' --database='${cfg.dataDir}/database.boltdb'";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"${cfg.package}/bin/filebrowser --config='${cfg.dataDir}/config.json' --database='${cfg.dataDir}/database.boltdb'";
"${lib.getExe cfg.package} --config='${cfg.dataDir}/config.json' --database='${cfg.dataDir}/database.boltdb'";

Comment on lines +112 to +113
networking.firewall =
lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.settings.port ]; };
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
networking.firewall =
lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.settings.port ]; };
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.settings.port ];
};

Comment on lines +126 to +137
ExecStart = pkgs.writeShellScript "filebrowser-exec-start.sh" ''
${preamble}

${cmd} config set --address=${cfg.settings.address} || exit $?
${cmd} config set --port=${
builtins.toString cfg.settings.port
} || exit $?

exec ${cmd}
'';
};

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ExecStart = pkgs.writeShellScript "filebrowser-exec-start.sh" ''
${preamble}
${cmd} config set --address=${cfg.settings.address} || exit $?
${cmd} config set --port=${
builtins.toString cfg.settings.port
} || exit $?
exec ${cmd}
'';
};
};
script = ''
${preamble}
${cmd} config set --address=${cfg.settings.address} || exit $?
${cmd} config set --port=${toString cfg.settings.port} || exit $?
exec ${cmd}
'';

we don't need the extra wrapper here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants