Skip to content

Instantly share code, notes, and snippets.

@guillemcanal
Last active April 8, 2025 22:54
Show Gist options
  • Select an option

  • Save guillemcanal/dc6c69d6733d557d2ca477b302f9f889 to your computer and use it in GitHub Desktop.

Select an option

Save guillemcanal/dc6c69d6733d557d2ca477b302f9f889 to your computer and use it in GitHub Desktop.

Revisions

  1. guillemcanal revised this gist Apr 8, 2025. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    ## Nix and Home Manager

    ```shell
    sh <(curl -L https://nixos.org/nix/install) --no-daemon
    echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
    nix run home-manager/master -- init --switch
    ```
  2. guillemcanal revised this gist Apr 8, 2025. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ## Nix and Home Manager

    sh <(curl -L https://nixos.org/nix/install) --no-daemon
    echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
    nix run home-manager/master -- init --switch
    sh <(curl -L https://nixos.org/nix/install) --no-daemon
    echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
    nix run home-manager/master -- init --switch
  3. guillemcanal created this gist Apr 8, 2025.
    85 changes: 85 additions & 0 deletions flake.lock
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,85 @@
    {
    "nodes": {
    "flake-utils": {
    "locked": {
    "lastModified": 1659877975,
    "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
    "owner": "numtide",
    "repo": "flake-utils",
    "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
    "type": "github"
    },
    "original": {
    "owner": "numtide",
    "repo": "flake-utils",
    "type": "github"
    }
    },
    "home-manager": {
    "inputs": {
    "nixpkgs": [
    "nixpkgs"
    ]
    },
    "locked": {
    "lastModified": 1744038920,
    "narHash": "sha256-9a4V1wQXS8hXZtc7mRtz0qINkGW+C99aDrmXY6oYBFg=",
    "owner": "nix-community",
    "repo": "home-manager",
    "rev": "a4d8020820a85b47f842eae76ad083b0ec2a886a",
    "type": "github"
    },
    "original": {
    "owner": "nix-community",
    "repo": "home-manager",
    "type": "github"
    }
    },
    "nixGL": {
    "inputs": {
    "flake-utils": "flake-utils",
    "nixpkgs": [
    "nixpkgs"
    ]
    },
    "locked": {
    "lastModified": 1713543440,
    "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=",
    "owner": "nix-community",
    "repo": "nixGL",
    "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a",
    "type": "github"
    },
    "original": {
    "owner": "nix-community",
    "repo": "nixGL",
    "type": "github"
    }
    },
    "nixpkgs": {
    "locked": {
    "lastModified": 1743964447,
    "narHash": "sha256-nEo1t3Q0F+0jQ36HJfbJtiRU4OI+/0jX/iITURKe3EE=",
    "owner": "nixos",
    "repo": "nixpkgs",
    "rev": "063dece00c5a77e4a0ea24e5e5a5bd75232806f8",
    "type": "github"
    },
    "original": {
    "owner": "nixos",
    "ref": "nixos-unstable",
    "repo": "nixpkgs",
    "type": "github"
    }
    },
    "root": {
    "inputs": {
    "home-manager": "home-manager",
    "nixGL": "nixGL",
    "nixpkgs": "nixpkgs"
    }
    }
    },
    "root": "root",
    "version": 7
    }
    41 changes: 41 additions & 0 deletions flake.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    {
    description = "Home Manager configuration of guillem";

    inputs = {
    # Specify the source of Home Manager and Nixpkgs.
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager = {
    url = "github:nix-community/home-manager";
    inputs.nixpkgs.follows = "nixpkgs";
    };
    # @see https://github.com/nix-community/home-manager/issues/3968#issuecomment-2514739063
    nixGL = {
    url = "github:nix-community/nixGL";
    inputs.nixpkgs.follows = "nixpkgs";
    };
    };

    outputs = { nixpkgs, home-manager, nixGL, ... }:
    let
    system = "x86_64-linux";
    pkgs = import nixpkgs {
    inherit system;
    config.allowUnfree = true;
    };
    in {
    homeConfigurations."guillem" = home-manager.lib.homeManagerConfiguration {
    inherit pkgs;

    extraSpecialArgs = {
    inherit nixGL;
    };

    # Specify your home configuration modules here, for example,
    # the path to your home.nix.
    modules = [ ./home.nix ];

    # Optionally use extraSpecialArgs
    # to pass through arguments to home.nix
    };
    };
    }
    77 changes: 77 additions & 0 deletions home.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,77 @@
    { config, lib, pkgs, nixGL, ... }:

    let
    phpVersion = "84";
    phpPkg = builtins.getAttr ("php" + phpVersion) pkgs;
    phpPackages = builtins.getAttr ("php" + phpVersion + "Packages") pkgs;

    php = phpPkg.buildEnv {
    extensions = { all, ... }: with all; [
    xdebug
    redis
    amqp
    iconv
    readline
    tokenizer
    ];
    extraConfig = ''
    xdebug.mode=debug
    memory_limit=256M
    '';
    };

    node = pkgs.nodejs_22;

    yarn = pkgs.yarn.override {
    nodejs = node;
    };

    composer = phpPackages.composer.override {
    php = php;
    };

    psysh = phpPackages.psysh.override {
    php = php;
    };

    in {
    home.username = "guillem";
    home.homeDirectory = "/home/guillem";
    home.stateVersion = "24.11";

    fonts.fontconfig.enable = true;

    home.packages = [
    php
    psysh
    node
    yarn
    composer
    pkgs.symfony-cli
    pkgs.direnv
    pkgs.nerd-fonts.jetbrains-mono
    ];

    home.file = {
    # Define dotfiles here
    };

    home.sessionVariables = {
    EDITOR = "vim";
    };

    nixGL.packages = nixGL.packages;
    nixGL.defaultWrapper = "mesa";

    # @see https://github.com/clo4/ghostty-hm-module
    programs.ghostty = {
    enable = true;
    package = config.lib.nixGL.wrap pkgs.ghostty;
    settings = {
    font-size = 12;
    font-family = "JetBrainsMono Nerd Font";
    };
    };

    programs.home-manager.enable = true;
    }
    5 changes: 5 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ## Nix and Home Manager

    sh <(curl -L https://nixos.org/nix/install) --no-daemon
    echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
    nix run home-manager/master -- init --switch