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: reserve some uids/gids #2109

Merged
merged 1 commit into from Apr 6, 2014
Merged

Conversation

thoughtpolice
Copy link
Member

I have some NixOS modules for unfree software that I keep out of tree, and having UIDs/GIDs reserved is quite helpful to keep the branches sane.

@thoughtpolice
Copy link
Member Author

I'll note this conflicts with #2103 but I'll rebase which-ever happens to be merged first.

@shlevy
Copy link
Member

shlevy commented Apr 5, 2014

At Zalora we're using something like:

{ config, pkgs, ... }:
let
  #!!! When deleting a user, don't reuse uids
  # unless you know what you're doing
  uids = {
    # service name -> small number mapping here
    # e.g. foundationdb = 1;
  };

in {
  options = {
    zalora.daemonUids = pkgs.lib.mkOption {
      description = "uids for zalora daemon users.";
      internal = true;
      type = pkgs.lib.types.attrsOf pkgs.lib.types.int;
    };
  };

  config = {
    zalora.daemonUids = pkgs.lib.mapAttrs (name: value: 1000 - value) uids;
  };
}

@edolstra Any thoughts on if there's anything we can do upstream to make this kind of thing nicer? I guess username->uid hashing might help.

@thoughtpolice
Copy link
Member Author

So, I asked @edolstra the other day about this, and he said reserving UIDs in this case is fine. In my case, the software is (mostly) publicly available, just with a non-free license, and the packages/modules will be available in my nixpkgs branch as right now, unfree modules are (mostly) unwelcome. Hence having UIDs/GIDs upstream greatly simplifies keeping the branches rebased (otherwise, merges get complex as IDs change, and then permissions get botched on nixos-rebuild later because permissions change, too).

But I don't know what to do in the more general, this-service-is-really-proprietary-but-I-need-an-ID case. Hashing is one option. Another is to actually reserve a part of the ID space for non-upstream needs (say all UIDs/GIDs in the range [2^15, 2^16] and provide a slightly different API for mapping private ids to this ID space.)

I have some NixOS modules that I keep out of tree, and having UIDs/GIDs
reserved is quite helpful.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
@thoughtpolice
Copy link
Member Author

@shlevy @edolstra I have rebased this branch on top of HEAD, FWIW.

shlevy added a commit that referenced this pull request Apr 6, 2014
@shlevy shlevy merged commit 8d0259c into NixOS:master Apr 6, 2014
@thoughtpolice thoughtpolice deleted the reserve-ids branch April 6, 2014 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants