nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.91k stars 1.8k forks source link

Enabling postgresql on macOS #826

Closed rpearce closed 5 years ago

rpearce commented 5 years ago

Hi! I don't know if this question belongs in home-manager, but it's worth a shot. Disclaimer: still relatively noob at nix.

I've successfully installed postgresql_11 via this project, but I am not sure how to enable the postgresql service. Am I just doing this wrong? Here's what I'm working with:

home.nix ```nix { pkgs, ... }: let nixpkgsConfig = import ./nixpkgs/config.nix; user = import ./user.nix; xdg = import ./xdg.nix; in { nixpkgs = { config = nixpkgsConfig; }; xdg = xdg; home.packages = with pkgs; [ postgresql_11 # ...other packages ]; programs.home-manager = (import ./programs/home-manager.nix { }); # ...other programs home.file.".psqlrc".source = ../conf/.psqlrc; # ...other dotfiles } ```
nixpkgs/config.nix ```nix { allowBroken = true; allowUnfree = true; packageOverrides = pkgs: rec { # ...package overrides }; services.postgresql = pkgs: rec { enable = true; package = pkgs.postgresql_11; port = 5432; }; } ```

I have all of the CLI tools, but it doesn't seem like it's getting enabled, and I can't find any of the relevant files/services that should be created as per https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/databases/postgresql.nix.

λ psql
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Any help or guidance would be super helpful!

rycee commented 5 years ago

The modules in Home Manager are separate from the ones in NixOS and unfortunately they are incompatible with each other. Second, NixOS modules are only for NixOS, i.e., would not work under macOS. All services in HM and NixOS are run through systemd so they will not work under macOS.

Fortunately, the nix-darwin project seems to have a postgresql module that you could try.

rpearce commented 5 years ago

Okay, thanks for looking at it and explaining!