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

miniflux: init at 2.0.12 #49320

Merged
merged 2 commits into from Oct 29, 2018
Merged

miniflux: init at 2.0.12 #49320

merged 2 commits into from Oct 29, 2018

Conversation

benpye
Copy link
Contributor

@benpye benpye commented Oct 28, 2018

Motivation for this change

Adds Miniflux feed reader server. It's similar to TT-RSS. It would be helpful to have a service config but I have yet to get that far.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Fits CONTRIBUTING.md.

@dywedir
Copy link
Member

dywedir commented Oct 28, 2018

Thank you!

nitpick:

{ stdenv
- , lib
, buildGoPackage
- , go
, fetchFromGitHub
}:

@dywedir
Copy link
Member

dywedir commented Oct 29, 2018

@GrahamcOfBorg build miniflux

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: miniflux

Partial log (click to expand)

ok      miniflux.app/template   0.050s
installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/2pygjxsm4rp0s05j7i1d9g39m592ylla-miniflux-2.0.12-bin
shrinking /nix/store/2pygjxsm4rp0s05j7i1d9g39m592ylla-miniflux-2.0.12-bin/bin/miniflux
strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/2pygjxsm4rp0s05j7i1d9g39m592ylla-miniflux-2.0.12-bin/bin
patching script interpreter paths in /nix/store/2pygjxsm4rp0s05j7i1d9g39m592ylla-miniflux-2.0.12-bin
checking for references to /build in /nix/store/2pygjxsm4rp0s05j7i1d9g39m592ylla-miniflux-2.0.12-bin...
strip is /nix/store/p9akxn2sfy4wkhqdqa3li97pc6jaz3r1-binutils-2.30/bin/strip

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: miniflux

Partial log (click to expand)

installing
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/xh31wggh02h4n2fw509g32y438bvgsh4-miniflux-2.0.12-bin
shrinking /nix/store/xh31wggh02h4n2fw509g32y438bvgsh4-miniflux-2.0.12-bin/bin/miniflux
strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/xh31wggh02h4n2fw509g32y438bvgsh4-miniflux-2.0.12-bin/bin
patching script interpreter paths in /nix/store/xh31wggh02h4n2fw509g32y438bvgsh4-miniflux-2.0.12-bin
checking for references to /build in /nix/store/xh31wggh02h4n2fw509g32y438bvgsh4-miniflux-2.0.12-bin...
strip is /nix/store/vcc4svb8gy29g4pam2zja6llkbcwsyiq-binutils-2.30/bin/strip
/nix/store/xh31wggh02h4n2fw509g32y438bvgsh4-miniflux-2.0.12-bin

@dywedir dywedir merged commit bd4387f into NixOS:master Oct 29, 2018
@andir
Copy link
Member

andir commented Oct 29, 2018

@benpye I have been running miniflux for a while with out of tree modules & packages. Here is the module that I have lying around:

{ config, lib, pkgs, ...}:
let
  cfg = config.services.miniflux;

  # this is supposed to be used on localhost (in a container) only. The access
  # to the database is only possible from miniflux or whatever else the admin
  # decides to put in the same container..
  dbUser = "miniflux";
  dbPassword = "miniflux";
  dbHost = "localhost";
  dbName = "miniflux";
  pgSuperUser = config.services.postgresql.superUser;
in {
  options = with lib; {
    services.miniflux = {
      enable = mkEnableOption "miniflux";

      package = mkOption {
        type = types.package;
        example = "miniflux";
      };

      user = mkOption {
        type = types.str;
        default = "miniflux";
        example = "miniflux";
        description = ''
          User account the daemon will run under.
        '';
      };

      listenAddress = mkOption {
        type = types.str;
        default = "localhost";
        description = ''
          The host the daemon will listen on.
        '';
      };

      listenPort = mkOption  {
        type = types.int;
        default = 8080;
        example = "8080";
        description = ''
          The port the daemon will listen on.
        '';
      };

      extraConfig = mkOption {
        type = types.lines;
        default = "";
        example = ''
          CREATE_ADMIN=1
          ADMIN_USERNAME=clown
          ADMIN_PASSWORD=s3cret123
        '';
      };

      statePath = mkOption {
        type = types.str;
        default = "/var/miniflux/state";
        description = "miniflux state directory.";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    services.postgresql.enable = lib.mkDefault true;
    users.users."${cfg.user}" = {
      createHome = false;
    };
    systemd.services.miniflux = let
      configFile = pkgs.writeText "miniflux.conf" ''
        RUN_MIGRATIONS=1
        LISTEN_ADDR=${cfg.listenAddress}:${builtins.toString cfg.listenPort}
        DATABASE_URL="postgresql://${dbUser}:${dbPassword}@${dbHost}/${dbName}?sslmode=disable"
        ${cfg.extraConfig}
      '';
    in {
      description = "Miniflux service";
      preStart = ''
        mkdir -p ${cfg.statePath}
        if ! test -e "${cfg.statePath}/db-created"; then
          ${pkgs.sudo}/bin/sudo -u ${pgSuperUser} ${config.services.postgresql.package}/bin/psql postgres -c "CREATE ROLE ${dbUser} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${dbPassword}'"
          ${pkgs.sudo}/bin/sudo -u ${pgSuperUser} ${config.services.postgresql.package}/bin/createdb --owner ${dbUser} ${dbName}
          ${pkgs.sudo}/bin/sudo -u ${pgSuperUser} ${config.services.postgresql.package}/bin/psql ${dbName} -c "CREATE EXTENSION IF NOT EXISTS hstore"
        #  source ${configFile}
        #  ${pkgs.sudo}/bin/sudo -u ${cfg.user} ${cfg.package}/bin/miniflux -migrate
          touch ${cfg.statePath}/db-created
        fi
      '';
      serviceConfig = {
        PermissionsStartOnly = true;
        Type = "simple";
        EnvironmentFile = configFile;
        PrivateTmp = false;
        ExecStart = "${cfg.package}/bin/miniflux.app";
        User = cfg.user;
      };
    };
  };
}

It think the migration is done automatically now and thus I commented those lines out.. Not sure anymore. It is a very low priority task on my list....

You probably want to make the constants at the top of the file configurable. Feel free to ping me on a follow-up PR.

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

5 participants