8000 GitHub - xluffy/nix-config
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

xluffy/nix-config

Repository files navigation

Setup with Nix on macOS

built with nix

hosts (personal):

  • Apple Mac Mini M4
  • Dell Wyse 5070 Thin Client
  • TinyPC
  • Apple Mac Air M1

To install Nix on macOS as a multi-user installtion, run this command:

sh <(curl -L https://nixos.org/nix/install) --daemon --yes

If you want to configure the OS via Nix, you can install Nix Darwin. For me, I just want to use Nix for managing package and user environment config in home directory When using nix, we still need some tools before using home-manager, so take a look at shell.nix — it's a bootstrap script to set up those tools. 👆 This adds tools to your shell environment.

  • nix: gives you the nix CLI.
  • home-manager: useful if you want to run home-manager commands.
  • git: version control.

They'll be available whenever you run nix develop or nix-shell.

  • You can run nix develop (flake)
  • Or nix-shell (legacy)

OpenSSL

> openssl version -a

devenv

> devenv init

> cat devenv.nix
{ pkgs, ... }:

{
  packages = [
    # pkgs.openssl_1_1
  ];

  languages.python.enable = true;
  languages.python.version = "3.9.21";
  languages.python.venv.enable = true;
  languages.python.poetry.enable = true;
  languages.python.poetry.install.enable = true;
}

Specific package version

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    # Some particular revision for installing fd
    nixpkgs-fd.url = "github:nixos/nixpkgs/bf972dc380f36a3bf83db052380e55f0eaa7dcb6";

    home-manager = {
      url = "github:nix-community/home-manager/release-24.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = { nixpkgs, nixpkgs-unstable, home-manager, nixpkgs-fd, ... }:
  {
    #...
  };

NixOS vs home-manager

# configuration.nix
{config, pkgs, ...}: {
  environment.systemPackages = with pkgs; [
    rsync
  ];

  services.nginx = {
    enable = true;
  };
}
# home.nix
{config, pkgs, ...}: {
  home.file.foo.text = "bar";

  programs.fish = {
    enable = true;
  };
}

How to locate nix packages with specific files

nix-index is a tool to quickly locate the package providing a certain file in nixpkgs. But you need to generate a database locally and run this command to search

# create locally database
> nix run github:nix-community/nix-index#nix-index

# query
> nix run github:nix-community/nix-index#nix-locate -- bin/ip

In another side, nix-index-database provides pre-generated databases if you don't want to generate a database locally.

> nix run github:nix-community/nix-index-database bin/ip

Ref

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0