Developers profile
Powered by Home Manager, this project offers a variety of user profiles, each packed with command-line programs and configurations designed specifically for developers.
Leveraging the Nix package manager, Home Manager provides a declarative approach to managing a user's environment. It focuses on user-specific (non-global) packages and dotfiles, offering a "ready-to-use" profile for command-line enthusiasts. The cornerstone of this project is its commitment to reproducibility across all machines, ensuring consistent experiences for users in different environments.
Compatibility
This configuration has been rigorously tested and confirmed to work seamlessly on a range of operating systems, including:
- Any Linux
- Amazon Workspaces
- Apple MacOS
With this broad compatibility, developers can trust in a uniform setup process and working environment, regardless of their OS choice.
Requirements
-
Nix package manager
Ensure Nix is installed on your system. You could use the official Nix installer or the alternative Lix installer, which ships with a better installer, providing more features and covering more edge cases.
-
No root access required.
Installation
Install this developer profile in three steps:
-
Install Nix
sh <(curl -L https://nixos.org/nix/install) --daemon --no-channel-add
-
Enable a specific profile: To apply a profile to your user, execute the following command in a terminal, and restart your terminal afterwards:
nix --extra-experimental-features "flakes nix-command" run nixpkgs#nh -- home switch git+https://code.europa.eu/ecphp/devs-profile -c light -a -- --impure
Here, the
light
profile is used as an example. You can replace it with any other profile, such asdefault
, see the section Profiles for more information. -
Enable custom Nix configuration directives:
To enable custom configuration directives, you may need to edit the following file
~/.config/nix/nix.local.conf
. If the file does not exist, create it manually. This file can be used to set your access tokens. For example:access-tokens = github.com=<TOKEN> citnet.tech.ec.europa.eu=<TOKEN>
To check which configuration files are loaded by Nix, run the following command:
echo $NIX_USER_CONF_FILES
--impure
flag
Note about To use this home-manager profile, you must include the --impure
flag. This
necessity arises from the fact that the profile is designed to function with any
username on any machine. As usernames vary across different machines, it is
essential to have a method to read the current username within this profile.
This can be accomplished by accessing the environment variable USER
. However,
by design, Nix does not have permission to access local environment variables.
Adding the --impure
flag grants this access, ensuring that only this variable
can be read and the profile can function as intended.
Update
The flake.lock
file in this repository pins all necessary information for a
reproducible and fully functional environment. To update, rerun the installation
command. Nix ensures the user environment matches this repository's state.
Usage
Once installed, users will have access to the list of pre-installed and pre-configured software provided by the profile they selected.
Profiles
Default
The default profile is a more comprehensive setup, offering a wide range of tools to enhance and streamline your terminal-based development experience.
List of tools included:
-
Fish
(from thelight
profile) difftastic
fd
-
git
+ many custom aliases gnupg
lazygit
micro
ripgrep
starship
zoxide
Install it by doing:
nix --extra-experimental-features "flakes nix-command" run nixpkgs#nh -- home switch git+https://code.europa.eu/ecphp/devs-profile -c default -a -- --impure
Light
This profile is a lightweight profile, containing only the bare essentials for a
cool and efficient command-line experience using Fish
terminal. This is recommended for users who prefer a minimal setup or are using
it in a container.
- Setup the
Fish
shell with:direnv
- Add
nix-your-shell
to your shell prompt
Install it by doing:
nix --extra-experimental-features "flakes nix-command" run nixpkgs#nh -- home switch git+https://code.europa.eu/ecphp/devs-profile -c light -a -- --impure
More profiles?
Currently only 2 profiles are available, more profiles will be added in the future, each tailored to a specific use case. Feel free to suggest new profiles or contribute your own!
Customisations
git
git
comes with a handful of aliases, to list them use git aliases
. However,
the default configuration of git
is managed by nix
in ~/.config/git/config
and it's better to not modify this file directly. Therefore, if you want to make
changes in the git configuration, it is advised to create a file ~/.gitconfig
containing all your local changes, such as:
[user]
email = "username@domain"
name = "John Doe"
Extending a specific profile
Extending an existing profile is straightforward. Here's how you can do it:
# Add the devs-profile flake as an input
# inputs.devs-profile.url = "git+https://code.europa.eu/ecphp/devs-profile";
{
homeConfigurations.foobar = inputs.devs-profile.homeConfigurations.default.extendModules {
modules = [
<path to your custom module>
];
};
}
Testing
You can test each available profile individually within a temporary virtual
machine using a single command. This project uses nixos-generators
, allowing
you to generate a virtual machine for any specific profile you wish to test
using many existing formats (e.g.: QEMU, VirtualBox, etc.).
To test the light
profile in QEMU, execute the following commands:
# Replace `light` in the next line with the profile you want to test
nix build .#nixosConfigurations.light.config.system.build.vm --impure
./result/bin/run-nixos-vm
Multiple configuration formats are supported. For further details, please
consult the
Supported Formats
section in the nixos-generators
documentation.
Troubleshooting
On macOS, the installation may fail if Xcode is not installed because it
requires git
. To resolve this issue, run the command
nix shell nixpkgs#gitMinimal
before starting the installation. This command
provides a minimal version of git
that is sufficient to complete the
installation. Once installed, the git
command will be available within the
profile.