Skip to content

Commit

Permalink
优化 nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruixi-rebirth committed Feb 13, 2023
1 parent ba04fc5 commit e51e50e
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ config.h
autostart.sh
statusbar/

result
dwm
*.o
.ccls-cache/
Expand Down
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,36 @@ exec dwm

### Nix Flake

```sh
nix run github:yaocccc/dwm
下面是在 nixos configuration 中使用它的示例

```nix
{
description = "My configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
dwm.url = "github:yaocccc/dwm";
};
outputs = { nixpkgs, dwm, ... }:
{
nixosConfigurations = {
hostname = nixpkgs.lib.nixosSystem
{
system = "x86_64-linux";
modules = [
{
nixpkgs.overlays = [ dwm.overlays.default ];
services.xserver = {
enable = true;
windowManager.dwm.enable = true;
};
}
];
};
};
};
}
```

## 状态栏
Expand Down
7 changes: 4 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 40 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
in rec {
packages = flake-utils.lib.flattenTree {
dwm = pkgs.dwm.overrideAttrs (old: {
src = pkgs.lib.cleanSource self;
outputs =
{ self
, nixpkgs
, flake-utils
,
}:
let
overlay =
final: prev: {
dwm = prev.dwm.overrideAttrs (oldAttrs: rec {
postPatch = (oldAttrs.postPatch or "") + ''
cp -r DEF/* .
'';
version = "master";
src = ./.;
});
};
defaultPackage = packages.dwm;
apps.default = flake-utils.lib.mkApp {
drv = packages.dwm;
exePath = "/bin/dwm";
};
}
);
in
flake-utils.lib.eachDefaultSystem
(
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
};
in
rec {
packages.dwm = pkgs.dwm;
packages.default = pkgs.dwm;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ xorg.libX11 xorg.libXft xorg.libXinerama gcc ];
};
}
)
// { overlays.default = overlay; };
}

0 comments on commit e51e50e

Please sign in to comment.