Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nora Puchreiner
Nix
Commits
1a714952
Commit
1a714952
authored
8 years ago
by
Eelco Dolstra
Browse files
Options
Downloads
Patches
Plain Diff
nix path-info: Add
Forgot to commit this earlier...
parent
69e3ffb0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/nix/path-info.cc
+75
-0
75 additions, 0 deletions
src/nix/path-info.cc
with
75 additions
and
0 deletions
src/nix/path-info.cc
0 → 100644
+
75
−
0
View file @
1a714952
#include
"command.hh"
#include
"progress-bar.hh"
#include
"shared.hh"
#include
"store-api.hh"
#include
<iomanip>
using
namespace
nix
;
struct
CmdPathInfo
:
StorePathsCommand
{
bool
showSize
=
false
;
bool
showClosureSize
=
false
;
CmdPathInfo
()
{
mkFlag
(
's'
,
"size"
,
"print size of the NAR dump of each path"
,
&
showSize
);
mkFlag
(
'S'
,
"closure-size"
,
"print sum size of the NAR dumps of the closure of each path"
,
&
showClosureSize
);
}
std
::
string
name
()
override
{
return
"path-info"
;
}
std
::
string
description
()
override
{
return
"query information about store paths"
;
}
Examples
examples
()
override
{
return
{
Example
{
"To show the closure sizes of every path in the current NixOS system closure, sorted by size:"
,
"nix path-info -rS /run/current-system | sort -nk2"
},
Example
{
"To check the existence of a path in a binary cache:"
,
"nix path-info -r /nix/store/7qvk5c91...-geeqie-1.1 --store https://cache.nixos.org/"
},
};
}
void
run
(
ref
<
Store
>
store
,
Paths
storePaths
)
override
{
size_t
pathLen
=
0
;
for
(
auto
&
storePath
:
storePaths
)
pathLen
=
std
::
max
(
pathLen
,
storePath
.
size
());
for
(
auto
&
storePath
:
storePaths
)
{
if
(
!
store
->
isValidPath
(
storePath
))
throw
Error
(
format
(
"path ‘%s’ is not valid"
)
%
storePath
);
std
::
cout
<<
storePath
<<
std
::
string
(
pathLen
-
storePath
.
size
(),
' '
);
if
(
showSize
)
{
std
::
cout
<<
'\t'
<<
std
::
setw
(
11
)
<<
store
->
queryPathInfo
(
storePath
)
->
narSize
;
}
if
(
showClosureSize
)
{
size_t
totalSize
=
0
;
PathSet
closure
;
store
->
computeFSClosure
(
storePath
,
closure
,
false
,
false
);
for
(
auto
&
p
:
closure
)
totalSize
+=
store
->
queryPathInfo
(
p
)
->
narSize
;
std
::
cout
<<
'\t'
<<
std
::
setw
(
11
)
<<
totalSize
;
}
std
::
cout
<<
std
::
endl
;
}
}
};
static
RegisterCommand
r1
(
make_ref
<
CmdPathInfo
>
());
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment