nix wireshark没有根

wireshark没有根

both.nix
{ ... }:

{
  users.extraUsers.clever.extraGroups = [ "wireshark" ];
  users.extraGroups.wireshark.gid = 500;
}
17.03.nix
{ pkgs, ... }:

{
  security.wrappers.dumpcap = {
    source = "${pkgs.wireshark}/bin/dumpcap";
    permissions = "u+xs,g+x";
    owner = "root";
    group = "wireshark";
  };
}
16.09.nix
{ ... }:

{
security.setuidOwners = [
  {
    program = "dumpcap";
    owner = "root";
    group = "wireshark";
    setuid = true;
    setgid = false;
    permissions = "u+rx,g+x";
  }
  ];
}

nix patchelf util

patchelf util

32bit-simple-test.nix
with import <nixpkgs> { system = "i686-linux"; };
runCommandCC "filename" { buildInputs = [ gcc ]; } ''
cat <<EOF > $out
#!${stdenv.shell}
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath ${lib.makeLibraryPath [ zlib ]} \$1
EOF
chmod +x $out
''
simple-test.nix
with import <nixpkgs> {};
runCommandCC "filename" { buildInputs = [ gcc ]; } ''
cat <<EOF > $out
#!${stdenv.shell}
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath ${lib.makeLibraryPath [ zlib ]} \$1
EOF
chmod +x $out
''

nix gistfile1.nix

gistfile1.nix
with import <nixpkgs> {};
let vendorgl = (linuxPackages.nvidia_x11.override {
    libsOnly = true;
    kernel = null;
  }).overrideAttrs (oldAttrs: rec {

      name = "nvidia-x11-367.27-${pkgs.linuxPackages.kernel.version}";
      src = fetchurl {
        url = "http://download.nvidia.com/XFree86/Linux-x86_64/367.27/NVIDIA-Linux-x86_64-367.27.run";
        sha256 = "0000000000000000000000000000000000000000000000000000";
      };
    });
 in buildEnv { name = "opengl-drivers"; paths = [ vendorgl ]; }

nix 缓存键,configuration.nix

nix.conf
binary-caches = http://cache.earthtools.ca https://cache.nixos.org
binary-cache-public-keys = c2d.localnet-1:YTVKcy9ZO3tqPNxRqeYEYxSpUH5C8ykZ9ImUKuugf4c= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
cache-keys-configuration.nix
{ ... }:

{
  nix = {
    binaryCaches = [ "http://cache.earthtools.ca" ];
    binaryCachePublicKeys = [ "c2d.localnet-1:YTVKcy9ZO3tqPNxRqeYEYxSpUH5C8ykZ9ImUKuugf4c=" ];
  };
}

nix 试图找出nix shell

试图找出nix shell

shell.nix
{ pkgs ? import <nixpkgs> {}, pkgs_i686 ?  pkgs.pkgsi686Linux }:

rec {
        myGit = pkgs.git.overrideDerivation (attrs: {
                src = ./.;
                withManual = false;
                guiSupport = false;
                tcl=null;
        });
        env = runCommand "env" { buildInputs = [ myGit ]; } "";
}

nix gistfile1.nix

gistfile1.nix
let
  pkgs = import <nixpkgs> {};
  callPackage = pkgs.newScope self;
  self = {
    foo = callPackage ./foo {};
  };
in self

nix 执行-arch.nix

enforce-arch.sh
function enforceArch() {
  echo checking target arches
  for x in $out/lib/*.so; do
    echo checking $x
    readelf -A $x | grep "@target@"
  done
}
postInstallHooks+=(enforceArch)
enforce-arch.nix
{ stdenv, makeSetupHook }:

let
  target = if builtins.trace "system is ${stdenv.system}" stdenv.system == "armv6l-linux" then "Tag_CPU_arch: v6" else
    (if stdenv.system == "armv7l-linux" then "Tag_CPU_arch: v7" else "NOP");
in
if target == "NOP" then
    makeSetupHook {} ./nop.sh
else
    makeSetupHook { substitutions = { inherit target; NIX_DEBUG="1"; }; } ./enforce-arch.sh

nix vim.nix

vim.nix
{config,pkgs,...}:

{
  environment.etc.vimrc = {
    text = ''
      syntax on
      set nu
      set foldmethod=syntax
      set listchars=tab:->
      set list
      set backspace=indent,eol,start
      map <F7> :tabp<enter>
      map <F8> :tabn<enter>
    '';
  };
  environment.systemPackages = [ pkgs.vim ];
}

nix example.nix

example.nix
{ pkgs, lib, config, ... }:

with lib;
let
  cfg = config.stuff;
in {
  options.stuff = {
    chromium = mkEnableOption "chromium";
    firefox = mkEnableOption "firefox";
    flash = mkEnableOption "flash";
  };
  config = {
    environment.systemPackages = (optional cfg.chromium pkgs.chromium) ++ (optional cfg.firefox pkgs.firefox);
    nixpkgs.config = {
      chromium = {
        enablePepperFlash = cfg.flash;
      };
      firefox = {
        enableAdobeFlash = cfg.flash;
      };
    };
  };
}

nix default.nix

default.nix
with import <nixpkgs> { config = {}; };

let
  callPackage = pkgs.newScope self;
  self = {
    foo = callPackage ./foo.nix {};
    bar = callPackage ./bar.nix {};
  };
in self